diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py index 13964e6e628e..4b22a7301833 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py @@ -31,6 +31,12 @@ BulkDeleteConversationsMetadata, BulkDeleteConversationsRequest, BulkDeleteConversationsResponse, + BulkDownloadFeedbackLabelsMetadata, + BulkDownloadFeedbackLabelsRequest, + BulkDownloadFeedbackLabelsResponse, + BulkUploadFeedbackLabelsMetadata, + BulkUploadFeedbackLabelsRequest, + BulkUploadFeedbackLabelsResponse, CalculateIssueModelStatsRequest, CalculateIssueModelStatsResponse, CalculateStatsRequest, @@ -38,21 +44,33 @@ ConversationView, CreateAnalysisOperationMetadata, CreateAnalysisRequest, + CreateAnalysisRuleRequest, CreateConversationRequest, + CreateFeedbackLabelRequest, CreateIssueModelMetadata, CreateIssueModelRequest, CreatePhraseMatcherRequest, + CreateQaQuestionRequest, + CreateQaScorecardRequest, + CreateQaScorecardRevisionRequest, CreateViewRequest, DeleteAnalysisRequest, + DeleteAnalysisRuleRequest, DeleteConversationRequest, + DeleteFeedbackLabelRequest, DeleteIssueModelMetadata, DeleteIssueModelRequest, DeleteIssueRequest, DeletePhraseMatcherRequest, + DeleteQaQuestionRequest, + DeleteQaScorecardRequest, + DeleteQaScorecardRevisionRequest, DeleteViewRequest, DeployIssueModelMetadata, DeployIssueModelRequest, DeployIssueModelResponse, + DeployQaScorecardRevisionRequest, + Dimension, ExportInsightsDataMetadata, ExportInsightsDataRequest, ExportInsightsDataResponse, @@ -60,11 +78,16 @@ ExportIssueModelRequest, ExportIssueModelResponse, GetAnalysisRequest, + GetAnalysisRuleRequest, GetConversationRequest, GetEncryptionSpecRequest, + GetFeedbackLabelRequest, GetIssueModelRequest, GetIssueRequest, GetPhraseMatcherRequest, + GetQaQuestionRequest, + GetQaScorecardRequest, + GetQaScorecardRevisionRequest, GetSettingsRequest, GetViewRequest, ImportIssueModelMetadata, @@ -76,25 +99,48 @@ InitializeEncryptionSpecMetadata, InitializeEncryptionSpecRequest, InitializeEncryptionSpecResponse, + ListAllFeedbackLabelsRequest, + ListAllFeedbackLabelsResponse, ListAnalysesRequest, ListAnalysesResponse, + ListAnalysisRulesRequest, + ListAnalysisRulesResponse, ListConversationsRequest, ListConversationsResponse, + ListFeedbackLabelsRequest, + ListFeedbackLabelsResponse, ListIssueModelsRequest, ListIssueModelsResponse, ListIssuesRequest, ListIssuesResponse, ListPhraseMatchersRequest, ListPhraseMatchersResponse, + ListQaQuestionsRequest, + ListQaQuestionsResponse, + ListQaScorecardRevisionsRequest, + ListQaScorecardRevisionsResponse, + ListQaScorecardsRequest, + ListQaScorecardsResponse, ListViewsRequest, ListViewsResponse, + QueryMetricsMetadata, + QueryMetricsRequest, + QueryMetricsResponse, + TuneQaScorecardRevisionMetadata, + TuneQaScorecardRevisionRequest, + TuneQaScorecardRevisionResponse, UndeployIssueModelMetadata, UndeployIssueModelRequest, UndeployIssueModelResponse, + UndeployQaScorecardRevisionRequest, + UpdateAnalysisRuleRequest, UpdateConversationRequest, + UpdateFeedbackLabelRequest, UpdateIssueModelRequest, UpdateIssueRequest, UpdatePhraseMatcherRequest, + UpdateQaQuestionRequest, + UpdateQaScorecardRequest, UpdateSettingsRequest, UpdateViewRequest, UploadConversationMetadata, @@ -103,6 +149,7 @@ from google.cloud.contact_center_insights_v1.types.resources import ( Analysis, AnalysisResult, + AnalysisRule, AnnotationBoundary, AnnotatorSelector, AnswerFeedback, @@ -114,6 +161,7 @@ ConversationLevelSilence, ConversationParticipant, ConversationSummarizationSuggestionData, + DatasetValidationWarning, DialogflowIntent, DialogflowInteractionData, DialogflowSource, @@ -122,6 +170,7 @@ EntityMentionData, ExactMatchConfig, FaqAnswerData, + FeedbackLabel, GcsSource, HoldData, Intent, @@ -138,6 +187,11 @@ PhraseMatchRule, PhraseMatchRuleConfig, PhraseMatchRuleGroup, + QaAnswer, + QaQuestion, + QaScorecard, + QaScorecardResult, + QaScorecardRevision, RedactionConfig, RuntimeAnnotation, SentimentData, @@ -158,27 +212,45 @@ "BulkDeleteConversationsMetadata", "BulkDeleteConversationsRequest", "BulkDeleteConversationsResponse", + "BulkDownloadFeedbackLabelsMetadata", + "BulkDownloadFeedbackLabelsRequest", + "BulkDownloadFeedbackLabelsResponse", + "BulkUploadFeedbackLabelsMetadata", + "BulkUploadFeedbackLabelsRequest", + "BulkUploadFeedbackLabelsResponse", "CalculateIssueModelStatsRequest", "CalculateIssueModelStatsResponse", "CalculateStatsRequest", "CalculateStatsResponse", "CreateAnalysisOperationMetadata", "CreateAnalysisRequest", + "CreateAnalysisRuleRequest", "CreateConversationRequest", + "CreateFeedbackLabelRequest", "CreateIssueModelMetadata", "CreateIssueModelRequest", "CreatePhraseMatcherRequest", + "CreateQaQuestionRequest", + "CreateQaScorecardRequest", + "CreateQaScorecardRevisionRequest", "CreateViewRequest", "DeleteAnalysisRequest", + "DeleteAnalysisRuleRequest", "DeleteConversationRequest", + "DeleteFeedbackLabelRequest", "DeleteIssueModelMetadata", "DeleteIssueModelRequest", "DeleteIssueRequest", "DeletePhraseMatcherRequest", + "DeleteQaQuestionRequest", + "DeleteQaScorecardRequest", + "DeleteQaScorecardRevisionRequest", "DeleteViewRequest", "DeployIssueModelMetadata", "DeployIssueModelRequest", "DeployIssueModelResponse", + "DeployQaScorecardRevisionRequest", + "Dimension", "ExportInsightsDataMetadata", "ExportInsightsDataRequest", "ExportInsightsDataResponse", @@ -186,11 +258,16 @@ "ExportIssueModelRequest", "ExportIssueModelResponse", "GetAnalysisRequest", + "GetAnalysisRuleRequest", "GetConversationRequest", "GetEncryptionSpecRequest", + "GetFeedbackLabelRequest", "GetIssueModelRequest", "GetIssueRequest", "GetPhraseMatcherRequest", + "GetQaQuestionRequest", + "GetQaScorecardRequest", + "GetQaScorecardRevisionRequest", "GetSettingsRequest", "GetViewRequest", "ImportIssueModelMetadata", @@ -202,25 +279,48 @@ "InitializeEncryptionSpecMetadata", "InitializeEncryptionSpecRequest", "InitializeEncryptionSpecResponse", + "ListAllFeedbackLabelsRequest", + "ListAllFeedbackLabelsResponse", "ListAnalysesRequest", "ListAnalysesResponse", + "ListAnalysisRulesRequest", + "ListAnalysisRulesResponse", "ListConversationsRequest", "ListConversationsResponse", + "ListFeedbackLabelsRequest", + "ListFeedbackLabelsResponse", "ListIssueModelsRequest", "ListIssueModelsResponse", "ListIssuesRequest", "ListIssuesResponse", "ListPhraseMatchersRequest", "ListPhraseMatchersResponse", + "ListQaQuestionsRequest", + "ListQaQuestionsResponse", + "ListQaScorecardRevisionsRequest", + "ListQaScorecardRevisionsResponse", + "ListQaScorecardsRequest", + "ListQaScorecardsResponse", "ListViewsRequest", "ListViewsResponse", + "QueryMetricsMetadata", + "QueryMetricsRequest", + "QueryMetricsResponse", + "TuneQaScorecardRevisionMetadata", + "TuneQaScorecardRevisionRequest", + "TuneQaScorecardRevisionResponse", "UndeployIssueModelMetadata", "UndeployIssueModelRequest", "UndeployIssueModelResponse", + "UndeployQaScorecardRevisionRequest", + "UpdateAnalysisRuleRequest", "UpdateConversationRequest", + "UpdateFeedbackLabelRequest", "UpdateIssueModelRequest", "UpdateIssueRequest", "UpdatePhraseMatcherRequest", + "UpdateQaQuestionRequest", + "UpdateQaScorecardRequest", "UpdateSettingsRequest", "UpdateViewRequest", "UploadConversationMetadata", @@ -228,6 +328,7 @@ "ConversationView", "Analysis", "AnalysisResult", + "AnalysisRule", "AnnotationBoundary", "AnnotatorSelector", "AnswerFeedback", @@ -247,6 +348,7 @@ "EntityMentionData", "ExactMatchConfig", "FaqAnswerData", + "FeedbackLabel", "GcsSource", "HoldData", "Intent", @@ -263,6 +365,11 @@ "PhraseMatchRule", "PhraseMatchRuleConfig", "PhraseMatchRuleGroup", + "QaAnswer", + "QaQuestion", + "QaScorecard", + "QaScorecardResult", + "QaScorecardRevision", "RedactionConfig", "RuntimeAnnotation", "SentimentData", @@ -272,4 +379,5 @@ "SmartReplyData", "SpeechConfig", "View", + "DatasetValidationWarning", ) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py index 8548409a4056..1f89885c46c4 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py @@ -29,6 +29,12 @@ BulkDeleteConversationsMetadata, BulkDeleteConversationsRequest, BulkDeleteConversationsResponse, + BulkDownloadFeedbackLabelsMetadata, + BulkDownloadFeedbackLabelsRequest, + BulkDownloadFeedbackLabelsResponse, + BulkUploadFeedbackLabelsMetadata, + BulkUploadFeedbackLabelsRequest, + BulkUploadFeedbackLabelsResponse, CalculateIssueModelStatsRequest, CalculateIssueModelStatsResponse, CalculateStatsRequest, @@ -36,21 +42,33 @@ ConversationView, CreateAnalysisOperationMetadata, CreateAnalysisRequest, + CreateAnalysisRuleRequest, CreateConversationRequest, + CreateFeedbackLabelRequest, CreateIssueModelMetadata, CreateIssueModelRequest, CreatePhraseMatcherRequest, + CreateQaQuestionRequest, + CreateQaScorecardRequest, + CreateQaScorecardRevisionRequest, CreateViewRequest, DeleteAnalysisRequest, + DeleteAnalysisRuleRequest, DeleteConversationRequest, + DeleteFeedbackLabelRequest, DeleteIssueModelMetadata, DeleteIssueModelRequest, DeleteIssueRequest, DeletePhraseMatcherRequest, + DeleteQaQuestionRequest, + DeleteQaScorecardRequest, + DeleteQaScorecardRevisionRequest, DeleteViewRequest, DeployIssueModelMetadata, DeployIssueModelRequest, DeployIssueModelResponse, + DeployQaScorecardRevisionRequest, + Dimension, ExportInsightsDataMetadata, ExportInsightsDataRequest, ExportInsightsDataResponse, @@ -58,11 +76,16 @@ ExportIssueModelRequest, ExportIssueModelResponse, GetAnalysisRequest, + GetAnalysisRuleRequest, GetConversationRequest, GetEncryptionSpecRequest, + GetFeedbackLabelRequest, GetIssueModelRequest, GetIssueRequest, GetPhraseMatcherRequest, + GetQaQuestionRequest, + GetQaScorecardRequest, + GetQaScorecardRevisionRequest, GetSettingsRequest, GetViewRequest, ImportIssueModelMetadata, @@ -74,25 +97,48 @@ InitializeEncryptionSpecMetadata, InitializeEncryptionSpecRequest, InitializeEncryptionSpecResponse, + ListAllFeedbackLabelsRequest, + ListAllFeedbackLabelsResponse, ListAnalysesRequest, ListAnalysesResponse, + ListAnalysisRulesRequest, + ListAnalysisRulesResponse, ListConversationsRequest, ListConversationsResponse, + ListFeedbackLabelsRequest, + ListFeedbackLabelsResponse, ListIssueModelsRequest, ListIssueModelsResponse, ListIssuesRequest, ListIssuesResponse, ListPhraseMatchersRequest, ListPhraseMatchersResponse, + ListQaQuestionsRequest, + ListQaQuestionsResponse, + ListQaScorecardRevisionsRequest, + ListQaScorecardRevisionsResponse, + ListQaScorecardsRequest, + ListQaScorecardsResponse, ListViewsRequest, ListViewsResponse, + QueryMetricsMetadata, + QueryMetricsRequest, + QueryMetricsResponse, + TuneQaScorecardRevisionMetadata, + TuneQaScorecardRevisionRequest, + TuneQaScorecardRevisionResponse, UndeployIssueModelMetadata, UndeployIssueModelRequest, UndeployIssueModelResponse, + UndeployQaScorecardRevisionRequest, + UpdateAnalysisRuleRequest, UpdateConversationRequest, + UpdateFeedbackLabelRequest, UpdateIssueModelRequest, UpdateIssueRequest, UpdatePhraseMatcherRequest, + UpdateQaQuestionRequest, + UpdateQaScorecardRequest, UpdateSettingsRequest, UpdateViewRequest, UploadConversationMetadata, @@ -101,6 +147,7 @@ from .types.resources import ( Analysis, AnalysisResult, + AnalysisRule, AnnotationBoundary, AnnotatorSelector, AnswerFeedback, @@ -112,6 +159,7 @@ ConversationLevelSilence, ConversationParticipant, ConversationSummarizationSuggestionData, + DatasetValidationWarning, DialogflowIntent, DialogflowInteractionData, DialogflowSource, @@ -120,6 +168,7 @@ EntityMentionData, ExactMatchConfig, FaqAnswerData, + FeedbackLabel, GcsSource, HoldData, Intent, @@ -136,6 +185,11 @@ PhraseMatchRule, PhraseMatchRuleConfig, PhraseMatchRuleGroup, + QaAnswer, + QaQuestion, + QaScorecard, + QaScorecardResult, + QaScorecardRevision, RedactionConfig, RuntimeAnnotation, SentimentData, @@ -151,6 +205,7 @@ "ContactCenterInsightsAsyncClient", "Analysis", "AnalysisResult", + "AnalysisRule", "AnnotationBoundary", "AnnotatorSelector", "AnswerFeedback", @@ -161,6 +216,12 @@ "BulkDeleteConversationsMetadata", "BulkDeleteConversationsRequest", "BulkDeleteConversationsResponse", + "BulkDownloadFeedbackLabelsMetadata", + "BulkDownloadFeedbackLabelsRequest", + "BulkDownloadFeedbackLabelsResponse", + "BulkUploadFeedbackLabelsMetadata", + "BulkUploadFeedbackLabelsRequest", + "BulkUploadFeedbackLabelsResponse", "CalculateIssueModelStatsRequest", "CalculateIssueModelStatsResponse", "CalculateStatsRequest", @@ -176,24 +237,37 @@ "ConversationView", "CreateAnalysisOperationMetadata", "CreateAnalysisRequest", + "CreateAnalysisRuleRequest", "CreateConversationRequest", + "CreateFeedbackLabelRequest", "CreateIssueModelMetadata", "CreateIssueModelRequest", "CreatePhraseMatcherRequest", + "CreateQaQuestionRequest", + "CreateQaScorecardRequest", + "CreateQaScorecardRevisionRequest", "CreateViewRequest", + "DatasetValidationWarning", "DeleteAnalysisRequest", + "DeleteAnalysisRuleRequest", "DeleteConversationRequest", + "DeleteFeedbackLabelRequest", "DeleteIssueModelMetadata", "DeleteIssueModelRequest", "DeleteIssueRequest", "DeletePhraseMatcherRequest", + "DeleteQaQuestionRequest", + "DeleteQaScorecardRequest", + "DeleteQaScorecardRevisionRequest", "DeleteViewRequest", "DeployIssueModelMetadata", "DeployIssueModelRequest", "DeployIssueModelResponse", + "DeployQaScorecardRevisionRequest", "DialogflowIntent", "DialogflowInteractionData", "DialogflowSource", + "Dimension", "EncryptionSpec", "Entity", "EntityMentionData", @@ -205,13 +279,19 @@ "ExportIssueModelRequest", "ExportIssueModelResponse", "FaqAnswerData", + "FeedbackLabel", "GcsSource", "GetAnalysisRequest", + "GetAnalysisRuleRequest", "GetConversationRequest", "GetEncryptionSpecRequest", + "GetFeedbackLabelRequest", "GetIssueModelRequest", "GetIssueRequest", "GetPhraseMatcherRequest", + "GetQaQuestionRequest", + "GetQaScorecardRequest", + "GetQaScorecardRevisionRequest", "GetSettingsRequest", "GetViewRequest", "HoldData", @@ -233,16 +313,28 @@ "IssueModel", "IssueModelLabelStats", "IssueModelResult", + "ListAllFeedbackLabelsRequest", + "ListAllFeedbackLabelsResponse", "ListAnalysesRequest", "ListAnalysesResponse", + "ListAnalysisRulesRequest", + "ListAnalysisRulesResponse", "ListConversationsRequest", "ListConversationsResponse", + "ListFeedbackLabelsRequest", + "ListFeedbackLabelsResponse", "ListIssueModelsRequest", "ListIssueModelsResponse", "ListIssuesRequest", "ListIssuesResponse", "ListPhraseMatchersRequest", "ListPhraseMatchersResponse", + "ListQaQuestionsRequest", + "ListQaQuestionsResponse", + "ListQaScorecardRevisionsRequest", + "ListQaScorecardRevisionsResponse", + "ListQaScorecardsRequest", + "ListQaScorecardsResponse", "ListViewsRequest", "ListViewsResponse", "PhraseMatchData", @@ -250,6 +342,14 @@ "PhraseMatchRuleConfig", "PhraseMatchRuleGroup", "PhraseMatcher", + "QaAnswer", + "QaQuestion", + "QaScorecard", + "QaScorecardResult", + "QaScorecardRevision", + "QueryMetricsMetadata", + "QueryMetricsRequest", + "QueryMetricsResponse", "RedactionConfig", "RuntimeAnnotation", "SentimentData", @@ -258,13 +358,21 @@ "SmartComposeSuggestionData", "SmartReplyData", "SpeechConfig", + "TuneQaScorecardRevisionMetadata", + "TuneQaScorecardRevisionRequest", + "TuneQaScorecardRevisionResponse", "UndeployIssueModelMetadata", "UndeployIssueModelRequest", "UndeployIssueModelResponse", + "UndeployQaScorecardRevisionRequest", + "UpdateAnalysisRuleRequest", "UpdateConversationRequest", + "UpdateFeedbackLabelRequest", "UpdateIssueModelRequest", "UpdateIssueRequest", "UpdatePhraseMatcherRequest", + "UpdateQaQuestionRequest", + "UpdateQaScorecardRequest", "UpdateSettingsRequest", "UpdateViewRequest", "UploadConversationMetadata", diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_metadata.json b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_metadata.json index 0e9a96c732d4..705ec329b80a 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_metadata.json +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_metadata.json @@ -20,6 +20,16 @@ "bulk_delete_conversations" ] }, + "BulkDownloadFeedbackLabels": { + "methods": [ + "bulk_download_feedback_labels" + ] + }, + "BulkUploadFeedbackLabels": { + "methods": [ + "bulk_upload_feedback_labels" + ] + }, "CalculateIssueModelStats": { "methods": [ "calculate_issue_model_stats" @@ -35,11 +45,21 @@ "create_analysis" ] }, + "CreateAnalysisRule": { + "methods": [ + "create_analysis_rule" + ] + }, "CreateConversation": { "methods": [ "create_conversation" ] }, + "CreateFeedbackLabel": { + "methods": [ + "create_feedback_label" + ] + }, "CreateIssueModel": { "methods": [ "create_issue_model" @@ -50,6 +70,21 @@ "create_phrase_matcher" ] }, + "CreateQaQuestion": { + "methods": [ + "create_qa_question" + ] + }, + "CreateQaScorecard": { + "methods": [ + "create_qa_scorecard" + ] + }, + "CreateQaScorecardRevision": { + "methods": [ + "create_qa_scorecard_revision" + ] + }, "CreateView": { "methods": [ "create_view" @@ -60,11 +95,21 @@ "delete_analysis" ] }, + "DeleteAnalysisRule": { + "methods": [ + "delete_analysis_rule" + ] + }, "DeleteConversation": { "methods": [ "delete_conversation" ] }, + "DeleteFeedbackLabel": { + "methods": [ + "delete_feedback_label" + ] + }, "DeleteIssue": { "methods": [ "delete_issue" @@ -80,6 +125,21 @@ "delete_phrase_matcher" ] }, + "DeleteQaQuestion": { + "methods": [ + "delete_qa_question" + ] + }, + "DeleteQaScorecard": { + "methods": [ + "delete_qa_scorecard" + ] + }, + "DeleteQaScorecardRevision": { + "methods": [ + "delete_qa_scorecard_revision" + ] + }, "DeleteView": { "methods": [ "delete_view" @@ -90,6 +150,11 @@ "deploy_issue_model" ] }, + "DeployQaScorecardRevision": { + "methods": [ + "deploy_qa_scorecard_revision" + ] + }, "ExportInsightsData": { "methods": [ "export_insights_data" @@ -105,6 +170,11 @@ "get_analysis" ] }, + "GetAnalysisRule": { + "methods": [ + "get_analysis_rule" + ] + }, "GetConversation": { "methods": [ "get_conversation" @@ -115,6 +185,11 @@ "get_encryption_spec" ] }, + "GetFeedbackLabel": { + "methods": [ + "get_feedback_label" + ] + }, "GetIssue": { "methods": [ "get_issue" @@ -130,6 +205,21 @@ "get_phrase_matcher" ] }, + "GetQaQuestion": { + "methods": [ + "get_qa_question" + ] + }, + "GetQaScorecard": { + "methods": [ + "get_qa_scorecard" + ] + }, + "GetQaScorecardRevision": { + "methods": [ + "get_qa_scorecard_revision" + ] + }, "GetSettings": { "methods": [ "get_settings" @@ -155,16 +245,31 @@ "initialize_encryption_spec" ] }, + "ListAllFeedbackLabels": { + "methods": [ + "list_all_feedback_labels" + ] + }, "ListAnalyses": { "methods": [ "list_analyses" ] }, + "ListAnalysisRules": { + "methods": [ + "list_analysis_rules" + ] + }, "ListConversations": { "methods": [ "list_conversations" ] }, + "ListFeedbackLabels": { + "methods": [ + "list_feedback_labels" + ] + }, "ListIssueModels": { "methods": [ "list_issue_models" @@ -180,21 +285,61 @@ "list_phrase_matchers" ] }, + "ListQaQuestions": { + "methods": [ + "list_qa_questions" + ] + }, + "ListQaScorecardRevisions": { + "methods": [ + "list_qa_scorecard_revisions" + ] + }, + "ListQaScorecards": { + "methods": [ + "list_qa_scorecards" + ] + }, "ListViews": { "methods": [ "list_views" ] }, + "QueryMetrics": { + "methods": [ + "query_metrics" + ] + }, + "TuneQaScorecardRevision": { + "methods": [ + "tune_qa_scorecard_revision" + ] + }, "UndeployIssueModel": { "methods": [ "undeploy_issue_model" ] }, + "UndeployQaScorecardRevision": { + "methods": [ + "undeploy_qa_scorecard_revision" + ] + }, + "UpdateAnalysisRule": { + "methods": [ + "update_analysis_rule" + ] + }, "UpdateConversation": { "methods": [ "update_conversation" ] }, + "UpdateFeedbackLabel": { + "methods": [ + "update_feedback_label" + ] + }, "UpdateIssue": { "methods": [ "update_issue" @@ -210,6 +355,16 @@ "update_phrase_matcher" ] }, + "UpdateQaQuestion": { + "methods": [ + "update_qa_question" + ] + }, + "UpdateQaScorecard": { + "methods": [ + "update_qa_scorecard" + ] + }, "UpdateSettings": { "methods": [ "update_settings" @@ -240,6 +395,16 @@ "bulk_delete_conversations" ] }, + "BulkDownloadFeedbackLabels": { + "methods": [ + "bulk_download_feedback_labels" + ] + }, + "BulkUploadFeedbackLabels": { + "methods": [ + "bulk_upload_feedback_labels" + ] + }, "CalculateIssueModelStats": { "methods": [ "calculate_issue_model_stats" @@ -255,11 +420,21 @@ "create_analysis" ] }, + "CreateAnalysisRule": { + "methods": [ + "create_analysis_rule" + ] + }, "CreateConversation": { "methods": [ "create_conversation" ] }, + "CreateFeedbackLabel": { + "methods": [ + "create_feedback_label" + ] + }, "CreateIssueModel": { "methods": [ "create_issue_model" @@ -270,6 +445,21 @@ "create_phrase_matcher" ] }, + "CreateQaQuestion": { + "methods": [ + "create_qa_question" + ] + }, + "CreateQaScorecard": { + "methods": [ + "create_qa_scorecard" + ] + }, + "CreateQaScorecardRevision": { + "methods": [ + "create_qa_scorecard_revision" + ] + }, "CreateView": { "methods": [ "create_view" @@ -280,11 +470,21 @@ "delete_analysis" ] }, + "DeleteAnalysisRule": { + "methods": [ + "delete_analysis_rule" + ] + }, "DeleteConversation": { "methods": [ "delete_conversation" ] }, + "DeleteFeedbackLabel": { + "methods": [ + "delete_feedback_label" + ] + }, "DeleteIssue": { "methods": [ "delete_issue" @@ -300,6 +500,21 @@ "delete_phrase_matcher" ] }, + "DeleteQaQuestion": { + "methods": [ + "delete_qa_question" + ] + }, + "DeleteQaScorecard": { + "methods": [ + "delete_qa_scorecard" + ] + }, + "DeleteQaScorecardRevision": { + "methods": [ + "delete_qa_scorecard_revision" + ] + }, "DeleteView": { "methods": [ "delete_view" @@ -310,6 +525,11 @@ "deploy_issue_model" ] }, + "DeployQaScorecardRevision": { + "methods": [ + "deploy_qa_scorecard_revision" + ] + }, "ExportInsightsData": { "methods": [ "export_insights_data" @@ -325,6 +545,11 @@ "get_analysis" ] }, + "GetAnalysisRule": { + "methods": [ + "get_analysis_rule" + ] + }, "GetConversation": { "methods": [ "get_conversation" @@ -335,6 +560,11 @@ "get_encryption_spec" ] }, + "GetFeedbackLabel": { + "methods": [ + "get_feedback_label" + ] + }, "GetIssue": { "methods": [ "get_issue" @@ -350,6 +580,21 @@ "get_phrase_matcher" ] }, + "GetQaQuestion": { + "methods": [ + "get_qa_question" + ] + }, + "GetQaScorecard": { + "methods": [ + "get_qa_scorecard" + ] + }, + "GetQaScorecardRevision": { + "methods": [ + "get_qa_scorecard_revision" + ] + }, "GetSettings": { "methods": [ "get_settings" @@ -375,16 +620,31 @@ "initialize_encryption_spec" ] }, + "ListAllFeedbackLabels": { + "methods": [ + "list_all_feedback_labels" + ] + }, "ListAnalyses": { "methods": [ "list_analyses" ] }, + "ListAnalysisRules": { + "methods": [ + "list_analysis_rules" + ] + }, "ListConversations": { "methods": [ "list_conversations" ] }, + "ListFeedbackLabels": { + "methods": [ + "list_feedback_labels" + ] + }, "ListIssueModels": { "methods": [ "list_issue_models" @@ -400,21 +660,61 @@ "list_phrase_matchers" ] }, + "ListQaQuestions": { + "methods": [ + "list_qa_questions" + ] + }, + "ListQaScorecardRevisions": { + "methods": [ + "list_qa_scorecard_revisions" + ] + }, + "ListQaScorecards": { + "methods": [ + "list_qa_scorecards" + ] + }, "ListViews": { "methods": [ "list_views" ] }, + "QueryMetrics": { + "methods": [ + "query_metrics" + ] + }, + "TuneQaScorecardRevision": { + "methods": [ + "tune_qa_scorecard_revision" + ] + }, "UndeployIssueModel": { "methods": [ "undeploy_issue_model" ] }, + "UndeployQaScorecardRevision": { + "methods": [ + "undeploy_qa_scorecard_revision" + ] + }, + "UpdateAnalysisRule": { + "methods": [ + "update_analysis_rule" + ] + }, "UpdateConversation": { "methods": [ "update_conversation" ] }, + "UpdateFeedbackLabel": { + "methods": [ + "update_feedback_label" + ] + }, "UpdateIssue": { "methods": [ "update_issue" @@ -430,6 +730,16 @@ "update_phrase_matcher" ] }, + "UpdateQaQuestion": { + "methods": [ + "update_qa_question" + ] + }, + "UpdateQaScorecard": { + "methods": [ + "update_qa_scorecard" + ] + }, "UpdateSettings": { "methods": [ "update_settings" @@ -460,6 +770,16 @@ "bulk_delete_conversations" ] }, + "BulkDownloadFeedbackLabels": { + "methods": [ + "bulk_download_feedback_labels" + ] + }, + "BulkUploadFeedbackLabels": { + "methods": [ + "bulk_upload_feedback_labels" + ] + }, "CalculateIssueModelStats": { "methods": [ "calculate_issue_model_stats" @@ -475,11 +795,21 @@ "create_analysis" ] }, + "CreateAnalysisRule": { + "methods": [ + "create_analysis_rule" + ] + }, "CreateConversation": { "methods": [ "create_conversation" ] }, + "CreateFeedbackLabel": { + "methods": [ + "create_feedback_label" + ] + }, "CreateIssueModel": { "methods": [ "create_issue_model" @@ -490,6 +820,21 @@ "create_phrase_matcher" ] }, + "CreateQaQuestion": { + "methods": [ + "create_qa_question" + ] + }, + "CreateQaScorecard": { + "methods": [ + "create_qa_scorecard" + ] + }, + "CreateQaScorecardRevision": { + "methods": [ + "create_qa_scorecard_revision" + ] + }, "CreateView": { "methods": [ "create_view" @@ -500,11 +845,21 @@ "delete_analysis" ] }, + "DeleteAnalysisRule": { + "methods": [ + "delete_analysis_rule" + ] + }, "DeleteConversation": { "methods": [ "delete_conversation" ] }, + "DeleteFeedbackLabel": { + "methods": [ + "delete_feedback_label" + ] + }, "DeleteIssue": { "methods": [ "delete_issue" @@ -520,6 +875,21 @@ "delete_phrase_matcher" ] }, + "DeleteQaQuestion": { + "methods": [ + "delete_qa_question" + ] + }, + "DeleteQaScorecard": { + "methods": [ + "delete_qa_scorecard" + ] + }, + "DeleteQaScorecardRevision": { + "methods": [ + "delete_qa_scorecard_revision" + ] + }, "DeleteView": { "methods": [ "delete_view" @@ -530,6 +900,11 @@ "deploy_issue_model" ] }, + "DeployQaScorecardRevision": { + "methods": [ + "deploy_qa_scorecard_revision" + ] + }, "ExportInsightsData": { "methods": [ "export_insights_data" @@ -545,6 +920,11 @@ "get_analysis" ] }, + "GetAnalysisRule": { + "methods": [ + "get_analysis_rule" + ] + }, "GetConversation": { "methods": [ "get_conversation" @@ -555,6 +935,11 @@ "get_encryption_spec" ] }, + "GetFeedbackLabel": { + "methods": [ + "get_feedback_label" + ] + }, "GetIssue": { "methods": [ "get_issue" @@ -570,6 +955,21 @@ "get_phrase_matcher" ] }, + "GetQaQuestion": { + "methods": [ + "get_qa_question" + ] + }, + "GetQaScorecard": { + "methods": [ + "get_qa_scorecard" + ] + }, + "GetQaScorecardRevision": { + "methods": [ + "get_qa_scorecard_revision" + ] + }, "GetSettings": { "methods": [ "get_settings" @@ -595,16 +995,31 @@ "initialize_encryption_spec" ] }, + "ListAllFeedbackLabels": { + "methods": [ + "list_all_feedback_labels" + ] + }, "ListAnalyses": { "methods": [ "list_analyses" ] }, + "ListAnalysisRules": { + "methods": [ + "list_analysis_rules" + ] + }, "ListConversations": { "methods": [ "list_conversations" ] }, + "ListFeedbackLabels": { + "methods": [ + "list_feedback_labels" + ] + }, "ListIssueModels": { "methods": [ "list_issue_models" @@ -620,21 +1035,61 @@ "list_phrase_matchers" ] }, + "ListQaQuestions": { + "methods": [ + "list_qa_questions" + ] + }, + "ListQaScorecardRevisions": { + "methods": [ + "list_qa_scorecard_revisions" + ] + }, + "ListQaScorecards": { + "methods": [ + "list_qa_scorecards" + ] + }, "ListViews": { "methods": [ "list_views" ] }, + "QueryMetrics": { + "methods": [ + "query_metrics" + ] + }, + "TuneQaScorecardRevision": { + "methods": [ + "tune_qa_scorecard_revision" + ] + }, "UndeployIssueModel": { "methods": [ "undeploy_issue_model" ] }, + "UndeployQaScorecardRevision": { + "methods": [ + "undeploy_qa_scorecard_revision" + ] + }, + "UpdateAnalysisRule": { + "methods": [ + "update_analysis_rule" + ] + }, "UpdateConversation": { "methods": [ "update_conversation" ] }, + "UpdateFeedbackLabel": { + "methods": [ + "update_feedback_label" + ] + }, "UpdateIssue": { "methods": [ "update_issue" @@ -650,6 +1105,16 @@ "update_phrase_matcher" ] }, + "UpdateQaQuestion": { + "methods": [ + "update_qa_question" + ] + }, + "UpdateQaScorecard": { + "methods": [ + "update_qa_scorecard" + ] + }, "UpdateSettings": { "methods": [ "update_settings" diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py index f810956ca26c..f92303aa73fc 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py @@ -44,6 +44,8 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -79,6 +81,10 @@ class ContactCenterInsightsAsyncClient: analysis_path = staticmethod(ContactCenterInsightsClient.analysis_path) parse_analysis_path = staticmethod(ContactCenterInsightsClient.parse_analysis_path) + analysis_rule_path = staticmethod(ContactCenterInsightsClient.analysis_rule_path) + parse_analysis_rule_path = staticmethod( + ContactCenterInsightsClient.parse_analysis_rule_path + ) conversation_path = staticmethod(ContactCenterInsightsClient.conversation_path) parse_conversation_path = staticmethod( ContactCenterInsightsClient.parse_conversation_path @@ -95,6 +101,10 @@ class ContactCenterInsightsAsyncClient: parse_encryption_spec_path = staticmethod( ContactCenterInsightsClient.parse_encryption_spec_path ) + feedback_label_path = staticmethod(ContactCenterInsightsClient.feedback_label_path) + parse_feedback_label_path = staticmethod( + ContactCenterInsightsClient.parse_feedback_label_path + ) issue_path = staticmethod(ContactCenterInsightsClient.issue_path) parse_issue_path = staticmethod(ContactCenterInsightsClient.parse_issue_path) issue_model_path = staticmethod(ContactCenterInsightsClient.issue_model_path) @@ -109,6 +119,26 @@ class ContactCenterInsightsAsyncClient: parse_phrase_matcher_path = staticmethod( ContactCenterInsightsClient.parse_phrase_matcher_path ) + qa_question_path = staticmethod(ContactCenterInsightsClient.qa_question_path) + parse_qa_question_path = staticmethod( + ContactCenterInsightsClient.parse_qa_question_path + ) + qa_scorecard_path = staticmethod(ContactCenterInsightsClient.qa_scorecard_path) + parse_qa_scorecard_path = staticmethod( + ContactCenterInsightsClient.parse_qa_scorecard_path + ) + qa_scorecard_result_path = staticmethod( + ContactCenterInsightsClient.qa_scorecard_result_path + ) + parse_qa_scorecard_result_path = staticmethod( + ContactCenterInsightsClient.parse_qa_scorecard_result_path + ) + qa_scorecard_revision_path = staticmethod( + ContactCenterInsightsClient.qa_scorecard_revision_path + ) + parse_qa_scorecard_revision_path = staticmethod( + ContactCenterInsightsClient.parse_qa_scorecard_revision_path + ) recognizer_path = staticmethod(ContactCenterInsightsClient.recognizer_path) parse_recognizer_path = staticmethod( ContactCenterInsightsClient.parse_recognizer_path @@ -4508,18 +4538,19 @@ async def sample_update_settings(): # Done; return the response. return response - async def get_encryption_spec( + async def create_analysis_rule( self, request: Optional[ - Union[contact_center_insights.GetEncryptionSpecRequest, dict] + Union[contact_center_insights.CreateAnalysisRuleRequest, dict] ] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, + analysis_rule: Optional[resources.AnalysisRule] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.EncryptionSpec: - r"""Gets location-level encryption key specification. + ) -> resources.AnalysisRule: + r"""Creates a analysis rule. .. code-block:: python @@ -4532,30 +4563,40 @@ async def get_encryption_spec( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - async def sample_get_encryption_spec(): + async def sample_create_analysis_rule(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() # Initialize request argument(s) - request = contact_center_insights_v1.GetEncryptionSpecRequest( - name="name_value", + request = contact_center_insights_v1.CreateAnalysisRuleRequest( + parent="parent_value", ) # Make the request - response = await client.get_encryption_spec(request=request) + response = await client.create_analysis_rule(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest, dict]]): - The request object. The request to get location-level - encryption specification. - name (:class:`str`): - Required. The name of the encryption - spec resource to get. + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRuleRequest, dict]]): + The request object. The request to create a analysis rule. analysis_rule_id + will be generated by the server. + parent (:class:`str`): + Required. The parent resource of the analysis rule. + Required. The location to create a analysis rule for. + Format: + ``projects//locations/`` or + ``projects//locations/`` - This corresponds to the ``name`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis_rule (:class:`google.cloud.contact_center_insights_v1.types.AnalysisRule`): + Required. The analysis rule resource + to create. + + This corresponds to the ``analysis_rule`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -4565,16 +4606,23 @@ async def sample_get_encryption_spec(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.EncryptionSpec: - A customer-managed encryption key - specification that can be applied to all - created resources (e.g. Conversation). + google.cloud.contact_center_insights_v1.types.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) + has_flattened_params = any([parent, analysis_rule]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -4583,24 +4631,26 @@ async def sample_get_encryption_spec(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.GetEncryptionSpecRequest): - request = contact_center_insights.GetEncryptionSpecRequest(request) + if not isinstance(request, contact_center_insights.CreateAnalysisRuleRequest): + request = contact_center_insights.CreateAnalysisRuleRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent + if analysis_rule is not None: + request.analysis_rule = analysis_rule # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.get_encryption_spec + self._client._transport.create_analysis_rule ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -4617,24 +4667,18 @@ async def sample_get_encryption_spec(): # Done; return the response. return response - async def initialize_encryption_spec( + async def get_analysis_rule( self, request: Optional[ - Union[contact_center_insights.InitializeEncryptionSpecRequest, dict] + Union[contact_center_insights.GetAnalysisRuleRequest, dict] ] = None, *, - encryption_spec: Optional[resources.EncryptionSpec] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Initializes a location-level encryption key - specification. An error will be thrown if the location - has resources already created before the initialization. - Once the encryption specification is initialized at a - location, it is immutable and all newly created - resources under the location will be encrypted with the - existing specification. + ) -> resources.AnalysisRule: + r"""Get a analysis rule. .. code-block:: python @@ -4647,41 +4691,30 @@ async def initialize_encryption_spec( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - async def sample_initialize_encryption_spec(): + async def sample_get_analysis_rule(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() # Initialize request argument(s) - encryption_spec = contact_center_insights_v1.EncryptionSpec() - encryption_spec.kms_key = "kms_key_value" - - request = contact_center_insights_v1.InitializeEncryptionSpecRequest( - encryption_spec=encryption_spec, + request = contact_center_insights_v1.GetAnalysisRuleRequest( + name="name_value", ) # Make the request - operation = client.initialize_encryption_spec(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() + response = await client.get_analysis_rule(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest, dict]]): - The request object. The request to initialize a - location-level encryption specification. - encryption_spec (:class:`google.cloud.contact_center_insights_v1.types.EncryptionSpec`): - Required. The encryption spec used for CMEK encryption. - It is required that the kms key is in the same region as - the endpoint. The same key will be used for all - provisioned resources, if encryption is available. If - the kms_key_name is left empty, no encryption will be - enforced. + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRuleRequest, dict]]): + The request object. The request for getting a analysis + rule. + name (:class:`str`): + Required. The name of the + AnalysisRule to get. - This corresponds to the ``encryption_spec`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -4691,19 +4724,23 @@ async def sample_initialize_encryption_spec(): sent along with the request as metadata. Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecResponse` - The response to initialize a location-level encryption - specification. + google.cloud.contact_center_insights_v1.types.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([encryption_spec]) + has_flattened_params = any([name]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -4712,28 +4749,24 @@ async def sample_initialize_encryption_spec(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance( - request, contact_center_insights.InitializeEncryptionSpecRequest - ): - request = contact_center_insights.InitializeEncryptionSpecRequest(request) + if not isinstance(request, contact_center_insights.GetAnalysisRuleRequest): + request = contact_center_insights.GetAnalysisRuleRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if encryption_spec is not None: - request.encryption_spec = encryption_spec + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.initialize_encryption_spec + self._client._transport.get_analysis_rule ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("encryption_spec.name", request.encryption_spec.name),) - ), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -4747,30 +4780,21 @@ async def sample_initialize_encryption_spec(): metadata=metadata, ) - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - contact_center_insights.InitializeEncryptionSpecResponse, - metadata_type=contact_center_insights.InitializeEncryptionSpecMetadata, - ) - # Done; return the response. return response - async def create_view( + async def list_analysis_rules( self, request: Optional[ - Union[contact_center_insights.CreateViewRequest, dict] + Union[contact_center_insights.ListAnalysisRulesRequest, dict] ] = None, *, parent: Optional[str] = None, - view: Optional[resources.View] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Creates a view. + ) -> pagers.ListAnalysisRulesAsyncPager: + r"""Lists analysis rules. .. code-block:: python @@ -4783,40 +4807,32 @@ async def create_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - async def sample_create_view(): + async def sample_list_analysis_rules(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() # Initialize request argument(s) - request = contact_center_insights_v1.CreateViewRequest( + request = contact_center_insights_v1.ListAnalysisRulesRequest( parent="parent_value", ) # Make the request - response = await client.create_view(request=request) + page_result = client.list_analysis_rules(request=request) # Handle the response - print(response) + async for response in page_result: + print(response) Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]]): - The request object. The request to create a view. + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListAnalysisRulesRequest, dict]]): + The request object. The request to list analysis rules. parent (:class:`str`): - Required. The parent resource of the view. Required. The - location to create a view for. Format: - ``projects//locations/`` or - ``projects//locations/`` + Required. The parent resource of the + analysis rules. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - view (:class:`google.cloud.contact_center_insights_v1.types.View`): - Required. The view resource to - create. - - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4824,13 +4840,18 @@ async def sample_create_view(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysisRulesAsyncPager: + The response of listing views. + + Iterating over this object will yield + results and resolve additional pages + automatically. + """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, view]) + has_flattened_params = any([parent]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -4839,20 +4860,18 @@ async def sample_create_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.CreateViewRequest): - request = contact_center_insights.CreateViewRequest(request) + if not isinstance(request, contact_center_insights.ListAnalysisRulesRequest): + request = contact_center_insights.ListAnalysisRulesRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent - if view is not None: - request.view = view # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.create_view + self._client._transport.list_analysis_rules ] # Certain fields should be provided within the metadata header; @@ -4872,19 +4891,33 @@ async def sample_create_view(): metadata=metadata, ) + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListAnalysisRulesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + # Done; return the response. return response - async def get_view( + async def update_analysis_rule( self, - request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, + request: Optional[ + Union[contact_center_insights.UpdateAnalysisRuleRequest, dict] + ] = None, *, - name: Optional[str] = None, + analysis_rule: Optional[resources.AnalysisRule] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Gets a view. + ) -> resources.AnalysisRule: + r"""Updates a analysis rule. .. code-block:: python @@ -4897,29 +4930,35 @@ async def get_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - async def sample_get_view(): + async def sample_update_analysis_rule(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() # Initialize request argument(s) - request = contact_center_insights_v1.GetViewRequest( - name="name_value", + request = contact_center_insights_v1.UpdateAnalysisRuleRequest( ) # Make the request - response = await client.get_view(request=request) + response = await client.update_analysis_rule(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]]): - The request object. The request to get a view. - name (:class:`str`): - Required. The name of the view to - get. + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateAnalysisRuleRequest, dict]]): + The request object. The request to update a analysis + rule. + analysis_rule (:class:`google.cloud.contact_center_insights_v1.types.AnalysisRule`): + Required. The new analysis rule. + This corresponds to the ``analysis_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. The list of fields to be updated. If the + update_mask is not provided, the update will be applied + to all fields. - This corresponds to the ``name`` field + This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -4929,13 +4968,23 @@ async def sample_get_view(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. + google.cloud.contact_center_insights_v1.types.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. + """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) + has_flattened_params = any([analysis_rule, update_mask]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -4944,22 +4993,28 @@ async def sample_get_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.GetViewRequest): - request = contact_center_insights.GetViewRequest(request) + if not isinstance(request, contact_center_insights.UpdateAnalysisRuleRequest): + request = contact_center_insights.UpdateAnalysisRuleRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if analysis_rule is not None: + request.analysis_rule = analysis_rule + if update_mask is not None: + request.update_mask = update_mask # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_view] + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_analysis_rule + ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata( + (("analysis_rule.name", request.analysis_rule.name),) + ), ) # Validate the universe domain. @@ -4976,16 +5031,18 @@ async def sample_get_view(): # Done; return the response. return response - async def list_views( + async def delete_analysis_rule( self, - request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, + request: Optional[ + Union[contact_center_insights.DeleteAnalysisRuleRequest, dict] + ] = None, *, - parent: Optional[str] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListViewsAsyncPager: - r"""Lists views. + ) -> None: + r"""Deletes a analysis rule. .. code-block:: python @@ -4998,30 +5055,27 @@ async def list_views( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - async def sample_list_views(): + async def sample_delete_analysis_rule(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() # Initialize request argument(s) - request = contact_center_insights_v1.ListViewsRequest( - parent="parent_value", + request = contact_center_insights_v1.DeleteAnalysisRuleRequest( + name="name_value", ) # Make the request - page_result = client.list_views(request=request) - - # Handle the response - async for response in page_result: - print(response) + await client.delete_analysis_rule(request=request) Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]]): - The request object. The request to list views. - parent (:class:`str`): - Required. The parent resource of the - views. + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRuleRequest, dict]]): + The request object. The request to delete a analysis + rule. + name (:class:`str`): + Required. The name of the analysis + rule to delete. - This corresponds to the ``parent`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -5029,20 +5083,11 @@ async def sample_list_views(): timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager: - The response of listing views. - - Iterating over this object will yield - results and resolve additional pages - automatically. - """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) + has_flattened_params = any([name]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5051,64 +5096,163 @@ async def sample_list_views(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.ListViewsRequest): - request = contact_center_insights.ListViewsRequest(request) + if not isinstance(request, contact_center_insights.DeleteAnalysisRuleRequest): + request = contact_center_insights.DeleteAnalysisRuleRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: - request.parent = parent + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.list_views + self._client._transport.delete_analysis_rule ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. self._client._validate_universe_domain() # Send the request. - response = await rpc( + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def get_encryption_spec( + self, + request: Optional[ + Union[contact_center_insights.GetEncryptionSpecRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.EncryptionSpec: + r"""Gets location-level encryption key specification. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_encryption_spec(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetEncryptionSpecRequest( + name="name_value", + ) + + # Make the request + response = await client.get_encryption_spec(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest, dict]]): + The request object. The request to get location-level + encryption specification. + name (:class:`str`): + Required. The name of the encryption + spec resource to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.EncryptionSpec: + A customer-managed encryption key specification that can be applied to all + created resources (e.g. Conversation). + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetEncryptionSpecRequest): + request = contact_center_insights.GetEncryptionSpecRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_encryption_spec + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListViewsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - # Done; return the response. return response - async def update_view( + async def initialize_encryption_spec( self, request: Optional[ - Union[contact_center_insights.UpdateViewRequest, dict] + Union[contact_center_insights.InitializeEncryptionSpecRequest, dict] ] = None, *, - view: Optional[resources.View] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, + encryption_spec: Optional[resources.EncryptionSpec] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Updates a view. + ) -> operation_async.AsyncOperation: + r"""Initializes a location-level encryption key + specification. An error will result if the location has + resources already created before the initialization. + After the encryption specification is initialized at a + location, it is immutable and all newly created + resources under the location will be encrypted with the + existing specification. .. code-block:: python @@ -5121,31 +5265,41 @@ async def update_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - async def sample_update_view(): + async def sample_initialize_encryption_spec(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() # Initialize request argument(s) - request = contact_center_insights_v1.UpdateViewRequest( + encryption_spec = contact_center_insights_v1.EncryptionSpec() + encryption_spec.kms_key = "kms_key_value" + + request = contact_center_insights_v1.InitializeEncryptionSpecRequest( + encryption_spec=encryption_spec, ) # Make the request - response = await client.update_view(request=request) + operation = client.initialize_encryption_spec(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() # Handle the response print(response) Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]]): - The request object. The request to update a view. - view (:class:`google.cloud.contact_center_insights_v1.types.View`): - Required. The new view. - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The list of fields to be updated. - This corresponds to the ``update_mask`` field + request (Optional[Union[google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest, dict]]): + The request object. The request to initialize a + location-level encryption specification. + encryption_spec (:class:`google.cloud.contact_center_insights_v1.types.EncryptionSpec`): + Required. The encryption spec used for CMEK encryption. + It is required that the kms key is in the same region as + the endpoint. The same key will be used for all + provisioned resources, if encryption is available. If + the ``kms_key_name`` field is left empty, no encryption + will be enforced. + + This corresponds to the ``encryption_spec`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -5155,13 +5309,19 @@ async def sample_update_view(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecResponse` + The response to initialize a location-level encryption + specification. + """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([view, update_mask]) + has_flattened_params = any([encryption_spec]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5170,27 +5330,27 @@ async def sample_update_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.UpdateViewRequest): - request = contact_center_insights.UpdateViewRequest(request) + if not isinstance( + request, contact_center_insights.InitializeEncryptionSpecRequest + ): + request = contact_center_insights.InitializeEncryptionSpecRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if view is not None: - request.view = view - if update_mask is not None: - request.update_mask = update_mask + if encryption_spec is not None: + request.encryption_spec = encryption_spec # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.update_view + self._client._transport.initialize_encryption_spec ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( - (("view.name", request.view.name),) + (("encryption_spec.name", request.encryption_spec.name),) ), ) @@ -5205,21 +5365,30 @@ async def sample_update_view(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.InitializeEncryptionSpecResponse, + metadata_type=contact_center_insights.InitializeEncryptionSpecMetadata, + ) + # Done; return the response. return response - async def delete_view( + async def create_view( self, request: Optional[ - Union[contact_center_insights.DeleteViewRequest, dict] + Union[contact_center_insights.CreateViewRequest, dict] ] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, + view: Optional[resources.View] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a view. + ) -> resources.View: + r"""Creates a view. .. code-block:: python @@ -5232,26 +5401,38 @@ async def delete_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - async def sample_delete_view(): + async def sample_create_view(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() # Initialize request argument(s) - request = contact_center_insights_v1.DeleteViewRequest( - name="name_value", + request = contact_center_insights_v1.CreateViewRequest( + parent="parent_value", ) # Make the request - await client.delete_view(request=request) + response = await client.create_view(request=request) + + # Handle the response + print(response) Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]]): - The request object. The request to delete a view. - name (:class:`str`): - Required. The name of the view to - delete. + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]]): + The request object. The request to create a view. + parent (:class:`str`): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` - This corresponds to the ``name`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + view (:class:`google.cloud.contact_center_insights_v1.types.View`): + Required. The view resource to + create. + + This corresponds to the ``view`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -5259,11 +5440,15 @@ async def sample_delete_view(): timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) + has_flattened_params = any([parent, view]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5272,37 +5457,3541 @@ async def sample_delete_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.DeleteViewRequest): - request = contact_center_insights.DeleteViewRequest(request) + if not isinstance(request, contact_center_insights.CreateViewRequest): + request = contact_center_insights.CreateViewRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent + if view is not None: + request.view = view # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.delete_view + self._client._transport.create_view ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. self._client._validate_universe_domain() # Send the request. - await rpc( + response = await rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) + # Done; return the response. + return response + + async def get_view( + self, + request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Gets a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetViewRequest( + name="name_value", + ) + + # Make the request + response = await client.get_view(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]]): + The request object. The request to get a view. + name (:class:`str`): + Required. The name of the view to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetViewRequest): + request = contact_center_insights.GetViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.get_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_views( + self, + request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListViewsAsyncPager: + r"""Lists views. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_views(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListViewsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_views(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]]): + The request object. The request to list views. + parent (:class:`str`): + Required. The parent resource of the + views. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager: + The response of listing views. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListViewsRequest): + request = contact_center_insights.ListViewsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_views + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListViewsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_view( + self, + request: Optional[ + Union[contact_center_insights.UpdateViewRequest, dict] + ] = None, + *, + view: Optional[resources.View] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Updates a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateViewRequest( + ) + + # Make the request + response = await client.update_view(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]]): + The request object. The request to update a view. + view (:class:`google.cloud.contact_center_insights_v1.types.View`): + Required. The new view. + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([view, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateViewRequest): + request = contact_center_insights.UpdateViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if view is not None: + request.view = view + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_view + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("view.name", request.view.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_view( + self, + request: Optional[ + Union[contact_center_insights.DeleteViewRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteViewRequest( + name="name_value", + ) + + # Make the request + await client.delete_view(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]]): + The request object. The request to delete a view. + name (:class:`str`): + Required. The name of the view to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteViewRequest): + request = contact_center_insights.DeleteViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_view + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def query_metrics( + self, + request: Optional[ + Union[contact_center_insights.QueryMetricsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Query metrics. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_query_metrics(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.QueryMetricsRequest( + location="location_value", + filter="filter_value", + ) + + # Make the request + operation = client.query_metrics(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.QueryMetricsRequest, dict]]): + The request object. The request for querying metrics. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.QueryMetricsResponse` + The response for querying metrics. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.QueryMetricsRequest): + request = contact_center_insights.QueryMetricsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.query_metrics + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("location", request.location),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.QueryMetricsResponse, + metadata_type=contact_center_insights.QueryMetricsMetadata, + ) + + # Done; return the response. + return response + + async def create_qa_question( + self, + request: Optional[ + Union[contact_center_insights.CreateQaQuestionRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + qa_question: Optional[resources.QaQuestion] = None, + qa_question_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaQuestion: + r"""Create a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaQuestionRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_qa_question(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateQaQuestionRequest, dict]]): + The request object. The request for creating a + QaQuestion. + parent (:class:`str`): + Required. The parent resource of the + QaQuestion. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_question (:class:`google.cloud.contact_center_insights_v1.types.QaQuestion`): + Required. The QaQuestion to create. + This corresponds to the ``qa_question`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_question_id (:class:`str`): + Optional. A unique ID for the new question. This ID will + become the final component of the question's resource + name. If no ID is specified, a server-generated ID will + be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-``. + + This corresponds to the ``qa_question_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaQuestion: + A single question to be scored by the + Insights QA feature. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, qa_question, qa_question_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.CreateQaQuestionRequest): + request = contact_center_insights.CreateQaQuestionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if qa_question is not None: + request.qa_question = qa_question + if qa_question_id is not None: + request.qa_question_id = qa_question_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_qa_question + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_qa_question( + self, + request: Optional[ + Union[contact_center_insights.GetQaQuestionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaQuestion: + r"""Gets a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaQuestionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_qa_question(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetQaQuestionRequest, dict]]): + The request object. The request for a QaQuestion. + name (:class:`str`): + Required. The name of the QaQuestion + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaQuestion: + A single question to be scored by the + Insights QA feature. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetQaQuestionRequest): + request = contact_center_insights.GetQaQuestionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_qa_question + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_qa_question( + self, + request: Optional[ + Union[contact_center_insights.UpdateQaQuestionRequest, dict] + ] = None, + *, + qa_question: Optional[resources.QaQuestion] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaQuestion: + r"""Updates a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaQuestionRequest( + ) + + # Make the request + response = await client.update_qa_question(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateQaQuestionRequest, dict]]): + The request object. The request for updating a + QaQuestion. + qa_question (:class:`google.cloud.contact_center_insights_v1.types.QaQuestion`): + Required. The QaQuestion to update. + This corresponds to the ``qa_question`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. All possible + fields can be updated by passing ``*``, or a subset of + the following updateable fields can be provided: + + - ``abbreviation`` + - ``answer_choices`` + - ``answer_instructions`` + - ``order`` + - ``question_body`` + - ``tags`` + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaQuestion: + A single question to be scored by the + Insights QA feature. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([qa_question, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateQaQuestionRequest): + request = contact_center_insights.UpdateQaQuestionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if qa_question is not None: + request.qa_question = qa_question + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_qa_question + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("qa_question.name", request.qa_question.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_qa_question( + self, + request: Optional[ + Union[contact_center_insights.DeleteQaQuestionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaQuestionRequest( + name="name_value", + ) + + # Make the request + await client.delete_qa_question(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteQaQuestionRequest, dict]]): + The request object. The request for deleting a + QaQuestion. + name (:class:`str`): + Required. The name of the QaQuestion + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteQaQuestionRequest): + request = contact_center_insights.DeleteQaQuestionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_qa_question + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_qa_questions( + self, + request: Optional[ + Union[contact_center_insights.ListQaQuestionsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQaQuestionsAsyncPager: + r"""Lists QaQuestions. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_qa_questions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaQuestionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_questions(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListQaQuestionsRequest, dict]]): + The request object. Request to list QaQuestions. + parent (:class:`str`): + Required. The parent resource of the + questions. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaQuestionsAsyncPager: + The response from a ListQaQuestions + request. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListQaQuestionsRequest): + request = contact_center_insights.ListQaQuestionsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_qa_questions + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListQaQuestionsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.CreateQaScorecardRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + qa_scorecard: Optional[resources.QaScorecard] = None, + qa_scorecard_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecard: + r"""Create a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_qa_scorecard(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateQaScorecardRequest, dict]]): + The request object. The request for creating a + QaScorecard. + parent (:class:`str`): + Required. The parent resource of the + QaScorecard. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard (:class:`google.cloud.contact_center_insights_v1.types.QaScorecard`): + Required. The QaScorecard to create. + This corresponds to the ``qa_scorecard`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard_id (:class:`str`): + Optional. A unique ID for the new QaScorecard. This ID + will become the final component of the QaScorecard's + resource name. If no ID is specified, a server-generated + ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-``. + + This corresponds to the ``qa_scorecard_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, qa_scorecard, qa_scorecard_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.CreateQaScorecardRequest): + request = contact_center_insights.CreateQaScorecardRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if qa_scorecard is not None: + request.qa_scorecard = qa_scorecard + if qa_scorecard_id is not None: + request.qa_scorecard_id = qa_scorecard_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_qa_scorecard + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.GetQaScorecardRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecard: + r"""Gets a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRequest( + name="name_value", + ) + + # Make the request + response = await client.get_qa_scorecard(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetQaScorecardRequest, dict]]): + The request object. The request for a QaScorecard. By + default, returns the latest revision. + name (:class:`str`): + Required. The name of the QaScorecard + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetQaScorecardRequest): + request = contact_center_insights.GetQaScorecardRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_qa_scorecard + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.UpdateQaScorecardRequest, dict] + ] = None, + *, + qa_scorecard: Optional[resources.QaScorecard] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecard: + r"""Updates a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaScorecardRequest( + ) + + # Make the request + response = await client.update_qa_scorecard(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateQaScorecardRequest, dict]]): + The request object. The request for updating a + QaScorecard. + qa_scorecard (:class:`google.cloud.contact_center_insights_v1.types.QaScorecard`): + Required. The QaScorecard to update. + This corresponds to the ``qa_scorecard`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. All possible + fields can be updated by passing ``*``, or a subset of + the following updateable fields can be provided: + + - ``description`` + - ``display_name`` + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([qa_scorecard, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateQaScorecardRequest): + request = contact_center_insights.UpdateQaScorecardRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if qa_scorecard is not None: + request.qa_scorecard = qa_scorecard + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_qa_scorecard + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("qa_scorecard.name", request.qa_scorecard.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.DeleteQaScorecardRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRequest( + name="name_value", + ) + + # Make the request + await client.delete_qa_scorecard(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRequest, dict]]): + The request object. The request for deleting a + QaScorecard. + name (:class:`str`): + Required. The name of the QaScorecard + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteQaScorecardRequest): + request = contact_center_insights.DeleteQaScorecardRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_qa_scorecard + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_qa_scorecards( + self, + request: Optional[ + Union[contact_center_insights.ListQaScorecardsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQaScorecardsAsyncPager: + r"""Lists QaScorecards. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_qa_scorecards(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecards(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListQaScorecardsRequest, dict]]): + The request object. Request to list QaScorecards. + parent (:class:`str`): + Required. The parent resource of the + scorecards. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardsAsyncPager: + The response from a ListQaScorecards + request. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListQaScorecardsRequest): + request = contact_center_insights.ListQaScorecardsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_qa_scorecards + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListQaScorecardsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.CreateQaScorecardRevisionRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + qa_scorecard_revision: Optional[resources.QaScorecardRevision] = None, + qa_scorecard_revision_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Creates a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRevisionRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateQaScorecardRevisionRequest, dict]]): + The request object. The request for creating a + QaScorecardRevision. + parent (:class:`str`): + Required. The parent resource of the + QaScorecardRevision. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard_revision (:class:`google.cloud.contact_center_insights_v1.types.QaScorecardRevision`): + Required. The QaScorecardRevision to + create. + + This corresponds to the ``qa_scorecard_revision`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard_revision_id (:class:`str`): + Optional. A unique ID for the new QaScorecardRevision. + This ID will become the final component of the + QaScorecardRevision's resource name. If no ID is + specified, a server-generated ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-``. + + This corresponds to the ``qa_scorecard_revision_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [parent, qa_scorecard_revision, qa_scorecard_revision_id] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.CreateQaScorecardRevisionRequest + ): + request = contact_center_insights.CreateQaScorecardRevisionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if qa_scorecard_revision is not None: + request.qa_scorecard_revision = qa_scorecard_revision + if qa_scorecard_revision_id is not None: + request.qa_scorecard_revision_id = qa_scorecard_revision_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.GetQaScorecardRevisionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Gets a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetQaScorecardRevisionRequest, dict]]): + The request object. The request for a + QaScorecardRevision. + name (:class:`str`): + Required. The name of the + QaScorecardRevision to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.GetQaScorecardRevisionRequest + ): + request = contact_center_insights.GetQaScorecardRevisionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def tune_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.TuneQaScorecardRevisionRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + filter: Optional[str] = None, + validate_only: Optional[bool] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Fine tune one or more QaModels. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_tune_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.TuneQaScorecardRevisionRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + operation = client.tune_qa_scorecard_revision(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionRequest, dict]]): + The request object. Request for TuneQaScorecardRevision + endpoint. + parent (:class:`str`): + Required. The parent resource for new + fine tuning job instance. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. Filter for selecting the + feedback labels that needs to be used + for training. This filter can be used to + limit the feedback labels used for + tuning to a feedback labels created or + updated for a specific time-window etc. + + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + validate_only (:class:`bool`): + Optional. Run in validate only mode, + no fine tuning will actually run. Data + quality validations like training data + distributions will run. Even when set to + false, the data quality validations will + still run but once the validations + complete we will proceed with the fine + tune, if applicable. + + This corresponds to the ``validate_only`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionResponse` + Response for TuneQaScorecardRevision endpoint. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, filter, validate_only]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.TuneQaScorecardRevisionRequest + ): + request = contact_center_insights.TuneQaScorecardRevisionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + if validate_only is not None: + request.validate_only = validate_only + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.tune_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.TuneQaScorecardRevisionResponse, + metadata_type=contact_center_insights.TuneQaScorecardRevisionMetadata, + ) + + # Done; return the response. + return response + + async def deploy_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.DeployQaScorecardRevisionRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Deploy a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_deploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.deploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeployQaScorecardRevisionRequest, dict]]): + The request object. The request to deploy a + QaScorecardRevision + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.DeployQaScorecardRevisionRequest + ): + request = contact_center_insights.DeployQaScorecardRevisionRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.deploy_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def undeploy_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.UndeployQaScorecardRevisionRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Undeploy a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_undeploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.undeploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UndeployQaScorecardRevisionRequest, dict]]): + The request object. The request to undeploy a + QaScorecardRevision + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.UndeployQaScorecardRevisionRequest + ): + request = contact_center_insights.UndeployQaScorecardRevisionRequest( + request + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.undeploy_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.DeleteQaScorecardRevisionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + await client.delete_qa_scorecard_revision(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRevisionRequest, dict]]): + The request object. The request to delete a + QaScorecardRevision. + name (:class:`str`): + Required. The name of the + QaScorecardRevision to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.DeleteQaScorecardRevisionRequest + ): + request = contact_center_insights.DeleteQaScorecardRevisionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_qa_scorecard_revisions( + self, + request: Optional[ + Union[contact_center_insights.ListQaScorecardRevisionsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQaScorecardRevisionsAsyncPager: + r"""Lists all revisions under the parent QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_qa_scorecard_revisions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecard_revisions(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsRequest, dict]]): + The request object. Request to list QaScorecardRevisions + parent (:class:`str`): + Required. The parent resource of the + scorecard revisions. To list all + revisions of all scorecards, substitute + the QaScorecard ID with a '-' character. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardRevisionsAsyncPager: + The response from a + ListQaScorecardRevisions request. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.ListQaScorecardRevisionsRequest + ): + request = contact_center_insights.ListQaScorecardRevisionsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_qa_scorecard_revisions + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListQaScorecardRevisionsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_feedback_label( + self, + request: Optional[ + Union[contact_center_insights.CreateFeedbackLabelRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + feedback_label: Optional[resources.FeedbackLabel] = None, + feedback_label_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FeedbackLabel: + r"""Create feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.CreateFeedbackLabelRequest( + parent="parent_value", + feedback_label=feedback_label, + ) + + # Make the request + response = await client.create_feedback_label(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateFeedbackLabelRequest, dict]]): + The request object. The request for creating a feedback + label. + parent (:class:`str`): + Required. The parent resource of the + feedback label. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feedback_label (:class:`google.cloud.contact_center_insights_v1.types.FeedbackLabel`): + Required. The feedback label to + create. + + This corresponds to the ``feedback_label`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feedback_label_id (:class:`str`): + Optional. The ID of the feedback + label to create. If one is not specified + it will be generated by the server. + + This corresponds to the ``feedback_label_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, feedback_label, feedback_label_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.CreateFeedbackLabelRequest): + request = contact_center_insights.CreateFeedbackLabelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if feedback_label is not None: + request.feedback_label = feedback_label + if feedback_label_id is not None: + request.feedback_label_id = feedback_label_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_feedback_label + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_feedback_labels( + self, + request: Optional[ + Union[contact_center_insights.ListFeedbackLabelsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeedbackLabelsAsyncPager: + r"""List feedback labels. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListFeedbackLabelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_feedback_labels(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsRequest, dict]]): + The request object. The request for listing feedback + labels. + parent (:class:`str`): + Required. The parent resource of the + feedback labels. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListFeedbackLabelsAsyncPager: + The response for listing feedback + labels. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListFeedbackLabelsRequest): + request = contact_center_insights.ListFeedbackLabelsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_feedback_labels + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListFeedbackLabelsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_feedback_label( + self, + request: Optional[ + Union[contact_center_insights.GetFeedbackLabelRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FeedbackLabel: + r"""Get feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + response = await client.get_feedback_label(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetFeedbackLabelRequest, dict]]): + The request object. The request for getting a feedback + label. + name (:class:`str`): + Required. The name of the feedback + label to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetFeedbackLabelRequest): + request = contact_center_insights.GetFeedbackLabelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_feedback_label + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_feedback_label( + self, + request: Optional[ + Union[contact_center_insights.UpdateFeedbackLabelRequest, dict] + ] = None, + *, + feedback_label: Optional[resources.FeedbackLabel] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FeedbackLabel: + r"""Update feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.UpdateFeedbackLabelRequest( + feedback_label=feedback_label, + ) + + # Make the request + response = await client.update_feedback_label(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateFeedbackLabelRequest, dict]]): + The request object. The request for updating a feedback + label. + feedback_label (:class:`google.cloud.contact_center_insights_v1.types.FeedbackLabel`): + Required. The feedback label to + update. + + This corresponds to the ``feedback_label`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be + updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([feedback_label, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateFeedbackLabelRequest): + request = contact_center_insights.UpdateFeedbackLabelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if feedback_label is not None: + request.feedback_label = feedback_label + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_feedback_label + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("feedback_label.name", request.feedback_label.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_feedback_label( + self, + request: Optional[ + Union[contact_center_insights.DeleteFeedbackLabelRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Delete feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + await client.delete_feedback_label(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteFeedbackLabelRequest, dict]]): + The request object. The request for deleting a feedback + label. + name (:class:`str`): + Required. The name of the feedback + label to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteFeedbackLabelRequest): + request = contact_center_insights.DeleteFeedbackLabelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_feedback_label + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_all_feedback_labels( + self, + request: Optional[ + Union[contact_center_insights.ListAllFeedbackLabelsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAllFeedbackLabelsAsyncPager: + r"""List all feedback labels by project number. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_all_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAllFeedbackLabelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_all_feedback_labels(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsRequest, dict]]): + The request object. The request for listing all feedback + labels. + parent (:class:`str`): + Required. The parent resource of all + feedback labels per project. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAllFeedbackLabelsAsyncPager: + The response for listing all feedback + labels. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.ListAllFeedbackLabelsRequest + ): + request = contact_center_insights.ListAllFeedbackLabelsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_all_feedback_labels + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListAllFeedbackLabelsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def bulk_upload_feedback_labels( + self, + request: Optional[ + Union[contact_center_insights.BulkUploadFeedbackLabelsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Upload feedback labels in bulk. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_bulk_upload_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.format_ = "JSON" + gcs_source.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkUploadFeedbackLabelsRequest( + gcs_source=gcs_source, + parent="parent_value", + ) + + # Make the request + operation = client.bulk_upload_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsRequest, dict]]): + The request object. The request for bulk uploading + feedback labels. + parent (:class:`str`): + Required. The parent resource for new + feedback labels. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsResponse` + Response for the Bulk Upload Feedback Labels API. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.BulkUploadFeedbackLabelsRequest + ): + request = contact_center_insights.BulkUploadFeedbackLabelsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.bulk_upload_feedback_labels + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.BulkUploadFeedbackLabelsResponse, + metadata_type=contact_center_insights.BulkUploadFeedbackLabelsMetadata, + ) + + # Done; return the response. + return response + + async def bulk_download_feedback_labels( + self, + request: Optional[ + Union[contact_center_insights.BulkDownloadFeedbackLabelsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Download feedback labels in bulk. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_bulk_download_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + gcs_destination = contact_center_insights_v1.GcsDestination() + gcs_destination.format_ = "JSON" + gcs_destination.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkDownloadFeedbackLabelsRequest( + gcs_destination=gcs_destination, + parent="parent_value", + ) + + # Make the request + operation = client.bulk_download_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest, dict]]): + The request object. Request for the + BulkDownloadFeedbackLabel endpoint. + parent (:class:`str`): + Required. The parent resource for new + feedback labels. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsResponse` + Response for the BulkDownloadFeedbackLabel endpoint. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.BulkDownloadFeedbackLabelsRequest + ): + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.bulk_download_feedback_labels + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.BulkDownloadFeedbackLabelsResponse, + metadata_type=contact_center_insights.BulkDownloadFeedbackLabelsMetadata, + ) + + # Done; return the response. + return response + async def list_operations( self, request: Optional[operations_pb2.ListOperationsRequest] = None, diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py index 084d0e6239c6..1a9d88b9f401 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py @@ -50,6 +50,8 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -222,6 +224,28 @@ def parse_analysis_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def analysis_rule_path( + project: str, + location: str, + analysis_rule: str, + ) -> str: + """Returns a fully-qualified analysis_rule string.""" + return "projects/{project}/locations/{location}/analysisRules/{analysis_rule}".format( + project=project, + location=location, + analysis_rule=analysis_rule, + ) + + @staticmethod + def parse_analysis_rule_path(path: str) -> Dict[str, str]: + """Parses a analysis_rule path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/analysisRules/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def conversation_path( project: str, @@ -286,6 +310,30 @@ def parse_encryption_spec_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def feedback_label_path( + project: str, + location: str, + conversation: str, + feedback_label: str, + ) -> str: + """Returns a fully-qualified feedback_label string.""" + return "projects/{project}/locations/{location}/conversations/{conversation}/feedbackLabels/{feedback_label}".format( + project=project, + location=location, + conversation=conversation, + feedback_label=feedback_label, + ) + + @staticmethod + def parse_feedback_label_path(path: str) -> Dict[str, str]: + """Parses a feedback_label path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/conversations/(?P.+?)/feedbackLabels/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def issue_path( project: str, @@ -378,6 +426,100 @@ def parse_phrase_matcher_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def qa_question_path( + project: str, + location: str, + qa_scorecard: str, + revision: str, + qa_question: str, + ) -> str: + """Returns a fully-qualified qa_question string.""" + return "projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}/revisions/{revision}/qaQuestions/{qa_question}".format( + project=project, + location=location, + qa_scorecard=qa_scorecard, + revision=revision, + qa_question=qa_question, + ) + + @staticmethod + def parse_qa_question_path(path: str) -> Dict[str, str]: + """Parses a qa_question path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/qaScorecards/(?P.+?)/revisions/(?P.+?)/qaQuestions/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def qa_scorecard_path( + project: str, + location: str, + qa_scorecard: str, + ) -> str: + """Returns a fully-qualified qa_scorecard string.""" + return "projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}".format( + project=project, + location=location, + qa_scorecard=qa_scorecard, + ) + + @staticmethod + def parse_qa_scorecard_path(path: str) -> Dict[str, str]: + """Parses a qa_scorecard path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/qaScorecards/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def qa_scorecard_result_path( + project: str, + location: str, + qa_scorecard_result: str, + ) -> str: + """Returns a fully-qualified qa_scorecard_result string.""" + return "projects/{project}/locations/{location}/qaScorecardResults/{qa_scorecard_result}".format( + project=project, + location=location, + qa_scorecard_result=qa_scorecard_result, + ) + + @staticmethod + def parse_qa_scorecard_result_path(path: str) -> Dict[str, str]: + """Parses a qa_scorecard_result path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/qaScorecardResults/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def qa_scorecard_revision_path( + project: str, + location: str, + qa_scorecard: str, + revision: str, + ) -> str: + """Returns a fully-qualified qa_scorecard_revision string.""" + return "projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}/revisions/{revision}".format( + project=project, + location=location, + qa_scorecard=qa_scorecard, + revision=revision, + ) + + @staticmethod + def parse_qa_scorecard_revision_path(path: str) -> Dict[str, str]: + """Parses a qa_scorecard_revision path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/qaScorecards/(?P.+?)/revisions/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def recognizer_path( project: str, @@ -4982,18 +5124,19 @@ def sample_update_settings(): # Done; return the response. return response - def get_encryption_spec( + def create_analysis_rule( self, request: Optional[ - Union[contact_center_insights.GetEncryptionSpecRequest, dict] + Union[contact_center_insights.CreateAnalysisRuleRequest, dict] ] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, + analysis_rule: Optional[resources.AnalysisRule] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.EncryptionSpec: - r"""Gets location-level encryption key specification. + ) -> resources.AnalysisRule: + r"""Creates a analysis rule. .. code-block:: python @@ -5006,30 +5149,40 @@ def get_encryption_spec( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - def sample_get_encryption_spec(): + def sample_create_analysis_rule(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsClient() # Initialize request argument(s) - request = contact_center_insights_v1.GetEncryptionSpecRequest( - name="name_value", + request = contact_center_insights_v1.CreateAnalysisRuleRequest( + parent="parent_value", ) # Make the request - response = client.get_encryption_spec(request=request) + response = client.create_analysis_rule(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest, dict]): - The request object. The request to get location-level - encryption specification. - name (str): - Required. The name of the encryption - spec resource to get. + request (Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRuleRequest, dict]): + The request object. The request to create a analysis rule. analysis_rule_id + will be generated by the server. + parent (str): + Required. The parent resource of the analysis rule. + Required. The location to create a analysis rule for. + Format: + ``projects//locations/`` or + ``projects//locations/`` - This corresponds to the ``name`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis_rule (google.cloud.contact_center_insights_v1.types.AnalysisRule): + Required. The analysis rule resource + to create. + + This corresponds to the ``analysis_rule`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -5039,16 +5192,23 @@ def sample_get_encryption_spec(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.EncryptionSpec: - A customer-managed encryption key - specification that can be applied to all - created resources (e.g. Conversation). + google.cloud.contact_center_insights_v1.types.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) + has_flattened_params = any([parent, analysis_rule]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5057,21 +5217,23 @@ def sample_get_encryption_spec(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.GetEncryptionSpecRequest): - request = contact_center_insights.GetEncryptionSpecRequest(request) + if not isinstance(request, contact_center_insights.CreateAnalysisRuleRequest): + request = contact_center_insights.CreateAnalysisRuleRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent + if analysis_rule is not None: + request.analysis_rule = analysis_rule # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_encryption_spec] + rpc = self._transport._wrapped_methods[self._transport.create_analysis_rule] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -5088,24 +5250,18 @@ def sample_get_encryption_spec(): # Done; return the response. return response - def initialize_encryption_spec( + def get_analysis_rule( self, request: Optional[ - Union[contact_center_insights.InitializeEncryptionSpecRequest, dict] + Union[contact_center_insights.GetAnalysisRuleRequest, dict] ] = None, *, - encryption_spec: Optional[resources.EncryptionSpec] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Initializes a location-level encryption key - specification. An error will be thrown if the location - has resources already created before the initialization. - Once the encryption specification is initialized at a - location, it is immutable and all newly created - resources under the location will be encrypted with the - existing specification. + ) -> resources.AnalysisRule: + r"""Get a analysis rule. .. code-block:: python @@ -5118,41 +5274,30 @@ def initialize_encryption_spec( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - def sample_initialize_encryption_spec(): + def sample_get_analysis_rule(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsClient() # Initialize request argument(s) - encryption_spec = contact_center_insights_v1.EncryptionSpec() - encryption_spec.kms_key = "kms_key_value" - - request = contact_center_insights_v1.InitializeEncryptionSpecRequest( - encryption_spec=encryption_spec, + request = contact_center_insights_v1.GetAnalysisRuleRequest( + name="name_value", ) # Make the request - operation = client.initialize_encryption_spec(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() + response = client.get_analysis_rule(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest, dict]): - The request object. The request to initialize a - location-level encryption specification. - encryption_spec (google.cloud.contact_center_insights_v1.types.EncryptionSpec): - Required. The encryption spec used for CMEK encryption. - It is required that the kms key is in the same region as - the endpoint. The same key will be used for all - provisioned resources, if encryption is available. If - the kms_key_name is left empty, no encryption will be - enforced. + request (Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRuleRequest, dict]): + The request object. The request for getting a analysis + rule. + name (str): + Required. The name of the + AnalysisRule to get. - This corresponds to the ``encryption_spec`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -5162,19 +5307,23 @@ def sample_initialize_encryption_spec(): sent along with the request as metadata. Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecResponse` - The response to initialize a location-level encryption - specification. + google.cloud.contact_center_insights_v1.types.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([encryption_spec]) + has_flattened_params = any([name]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5183,27 +5332,21 @@ def sample_initialize_encryption_spec(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance( - request, contact_center_insights.InitializeEncryptionSpecRequest - ): - request = contact_center_insights.InitializeEncryptionSpecRequest(request) + if not isinstance(request, contact_center_insights.GetAnalysisRuleRequest): + request = contact_center_insights.GetAnalysisRuleRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if encryption_spec is not None: - request.encryption_spec = encryption_spec + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[ - self._transport.initialize_encryption_spec - ] + rpc = self._transport._wrapped_methods[self._transport.get_analysis_rule] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("encryption_spec.name", request.encryption_spec.name),) - ), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -5217,30 +5360,21 @@ def sample_initialize_encryption_spec(): metadata=metadata, ) - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - contact_center_insights.InitializeEncryptionSpecResponse, - metadata_type=contact_center_insights.InitializeEncryptionSpecMetadata, - ) - # Done; return the response. return response - def create_view( + def list_analysis_rules( self, request: Optional[ - Union[contact_center_insights.CreateViewRequest, dict] + Union[contact_center_insights.ListAnalysisRulesRequest, dict] ] = None, *, parent: Optional[str] = None, - view: Optional[resources.View] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Creates a view. + ) -> pagers.ListAnalysisRulesPager: + r"""Lists analysis rules. .. code-block:: python @@ -5253,40 +5387,32 @@ def create_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - def sample_create_view(): + def sample_list_analysis_rules(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsClient() # Initialize request argument(s) - request = contact_center_insights_v1.CreateViewRequest( + request = contact_center_insights_v1.ListAnalysisRulesRequest( parent="parent_value", ) # Make the request - response = client.create_view(request=request) + page_result = client.list_analysis_rules(request=request) # Handle the response - print(response) + for response in page_result: + print(response) Args: - request (Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]): - The request object. The request to create a view. + request (Union[google.cloud.contact_center_insights_v1.types.ListAnalysisRulesRequest, dict]): + The request object. The request to list analysis rules. parent (str): - Required. The parent resource of the view. Required. The - location to create a view for. Format: - ``projects//locations/`` or - ``projects//locations/`` + Required. The parent resource of the + analysis rules. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - view (google.cloud.contact_center_insights_v1.types.View): - Required. The view resource to - create. - - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -5294,13 +5420,18 @@ def sample_create_view(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysisRulesPager: + The response of listing views. + + Iterating over this object will yield + results and resolve additional pages + automatically. + """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, view]) + has_flattened_params = any([parent]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5309,18 +5440,16 @@ def sample_create_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.CreateViewRequest): - request = contact_center_insights.CreateViewRequest(request) + if not isinstance(request, contact_center_insights.ListAnalysisRulesRequest): + request = contact_center_insights.ListAnalysisRulesRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent - if view is not None: - request.view = view # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_view] + rpc = self._transport._wrapped_methods[self._transport.list_analysis_rules] # Certain fields should be provided within the metadata header; # add these here. @@ -5339,19 +5468,33 @@ def sample_create_view(): metadata=metadata, ) + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListAnalysisRulesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + # Done; return the response. return response - def get_view( + def update_analysis_rule( self, - request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, + request: Optional[ + Union[contact_center_insights.UpdateAnalysisRuleRequest, dict] + ] = None, *, - name: Optional[str] = None, + analysis_rule: Optional[resources.AnalysisRule] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Gets a view. + ) -> resources.AnalysisRule: + r"""Updates a analysis rule. .. code-block:: python @@ -5364,29 +5507,3454 @@ def get_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - def sample_get_view(): + def sample_update_analysis_rule(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsClient() # Initialize request argument(s) - request = contact_center_insights_v1.GetViewRequest( - name="name_value", + request = contact_center_insights_v1.UpdateAnalysisRuleRequest( ) # Make the request - response = client.get_view(request=request) + response = client.update_analysis_rule(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]): - The request object. The request to get a view. - name (str): - Required. The name of the view to - get. + request (Union[google.cloud.contact_center_insights_v1.types.UpdateAnalysisRuleRequest, dict]): + The request object. The request to update a analysis + rule. + analysis_rule (google.cloud.contact_center_insights_v1.types.AnalysisRule): + Required. The new analysis rule. + This corresponds to the ``analysis_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. The list of fields to be updated. If the + update_mask is not provided, the update will be applied + to all fields. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([analysis_rule, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateAnalysisRuleRequest): + request = contact_center_insights.UpdateAnalysisRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if analysis_rule is not None: + request.analysis_rule = analysis_rule + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_analysis_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("analysis_rule.name", request.analysis_rule.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_analysis_rule( + self, + request: Optional[ + Union[contact_center_insights.DeleteAnalysisRuleRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a analysis rule. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteAnalysisRuleRequest( + name="name_value", + ) + + # Make the request + client.delete_analysis_rule(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRuleRequest, dict]): + The request object. The request to delete a analysis + rule. + name (str): + Required. The name of the analysis + rule to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteAnalysisRuleRequest): + request = contact_center_insights.DeleteAnalysisRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_analysis_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def get_encryption_spec( + self, + request: Optional[ + Union[contact_center_insights.GetEncryptionSpecRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.EncryptionSpec: + r"""Gets location-level encryption key specification. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_encryption_spec(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetEncryptionSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_encryption_spec(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest, dict]): + The request object. The request to get location-level + encryption specification. + name (str): + Required. The name of the encryption + spec resource to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.EncryptionSpec: + A customer-managed encryption key specification that can be applied to all + created resources (e.g. Conversation). + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetEncryptionSpecRequest): + request = contact_center_insights.GetEncryptionSpecRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_encryption_spec] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def initialize_encryption_spec( + self, + request: Optional[ + Union[contact_center_insights.InitializeEncryptionSpecRequest, dict] + ] = None, + *, + encryption_spec: Optional[resources.EncryptionSpec] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Initializes a location-level encryption key + specification. An error will result if the location has + resources already created before the initialization. + After the encryption specification is initialized at a + location, it is immutable and all newly created + resources under the location will be encrypted with the + existing specification. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_initialize_encryption_spec(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + encryption_spec = contact_center_insights_v1.EncryptionSpec() + encryption_spec.kms_key = "kms_key_value" + + request = contact_center_insights_v1.InitializeEncryptionSpecRequest( + encryption_spec=encryption_spec, + ) + + # Make the request + operation = client.initialize_encryption_spec(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest, dict]): + The request object. The request to initialize a + location-level encryption specification. + encryption_spec (google.cloud.contact_center_insights_v1.types.EncryptionSpec): + Required. The encryption spec used for CMEK encryption. + It is required that the kms key is in the same region as + the endpoint. The same key will be used for all + provisioned resources, if encryption is available. If + the ``kms_key_name`` field is left empty, no encryption + will be enforced. + + This corresponds to the ``encryption_spec`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecResponse` + The response to initialize a location-level encryption + specification. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([encryption_spec]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.InitializeEncryptionSpecRequest + ): + request = contact_center_insights.InitializeEncryptionSpecRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if encryption_spec is not None: + request.encryption_spec = encryption_spec + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.initialize_encryption_spec + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("encryption_spec.name", request.encryption_spec.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.InitializeEncryptionSpecResponse, + metadata_type=contact_center_insights.InitializeEncryptionSpecMetadata, + ) + + # Done; return the response. + return response + + def create_view( + self, + request: Optional[ + Union[contact_center_insights.CreateViewRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + view: Optional[resources.View] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Creates a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateViewRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_view(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]): + The request object. The request to create a view. + parent (str): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + view (google.cloud.contact_center_insights_v1.types.View): + Required. The view resource to + create. + + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, view]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.CreateViewRequest): + request = contact_center_insights.CreateViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if view is not None: + request.view = view + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_view( + self, + request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Gets a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetViewRequest( + name="name_value", + ) + + # Make the request + response = client.get_view(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]): + The request object. The request to get a view. + name (str): + Required. The name of the view to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetViewRequest): + request = contact_center_insights.GetViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_views( + self, + request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListViewsPager: + r"""Lists views. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_views(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListViewsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_views(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]): + The request object. The request to list views. + parent (str): + Required. The parent resource of the + views. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager: + The response of listing views. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListViewsRequest): + request = contact_center_insights.ListViewsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_views] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListViewsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_view( + self, + request: Optional[ + Union[contact_center_insights.UpdateViewRequest, dict] + ] = None, + *, + view: Optional[resources.View] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Updates a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateViewRequest( + ) + + # Make the request + response = client.update_view(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]): + The request object. The request to update a view. + view (google.cloud.contact_center_insights_v1.types.View): + Required. The new view. + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([view, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateViewRequest): + request = contact_center_insights.UpdateViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if view is not None: + request.view = view + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("view.name", request.view.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_view( + self, + request: Optional[ + Union[contact_center_insights.DeleteViewRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteViewRequest( + name="name_value", + ) + + # Make the request + client.delete_view(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]): + The request object. The request to delete a view. + name (str): + Required. The name of the view to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteViewRequest): + request = contact_center_insights.DeleteViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def query_metrics( + self, + request: Optional[ + Union[contact_center_insights.QueryMetricsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Query metrics. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_query_metrics(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.QueryMetricsRequest( + location="location_value", + filter="filter_value", + ) + + # Make the request + operation = client.query_metrics(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.QueryMetricsRequest, dict]): + The request object. The request for querying metrics. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.QueryMetricsResponse` + The response for querying metrics. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.QueryMetricsRequest): + request = contact_center_insights.QueryMetricsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.query_metrics] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("location", request.location),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.QueryMetricsResponse, + metadata_type=contact_center_insights.QueryMetricsMetadata, + ) + + # Done; return the response. + return response + + def create_qa_question( + self, + request: Optional[ + Union[contact_center_insights.CreateQaQuestionRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + qa_question: Optional[resources.QaQuestion] = None, + qa_question_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaQuestion: + r"""Create a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaQuestionRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_qa_question(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateQaQuestionRequest, dict]): + The request object. The request for creating a + QaQuestion. + parent (str): + Required. The parent resource of the + QaQuestion. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_question (google.cloud.contact_center_insights_v1.types.QaQuestion): + Required. The QaQuestion to create. + This corresponds to the ``qa_question`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_question_id (str): + Optional. A unique ID for the new question. This ID will + become the final component of the question's resource + name. If no ID is specified, a server-generated ID will + be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-``. + + This corresponds to the ``qa_question_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaQuestion: + A single question to be scored by the + Insights QA feature. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, qa_question, qa_question_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.CreateQaQuestionRequest): + request = contact_center_insights.CreateQaQuestionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if qa_question is not None: + request.qa_question = qa_question + if qa_question_id is not None: + request.qa_question_id = qa_question_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_qa_question] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_qa_question( + self, + request: Optional[ + Union[contact_center_insights.GetQaQuestionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaQuestion: + r"""Gets a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaQuestionRequest( + name="name_value", + ) + + # Make the request + response = client.get_qa_question(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetQaQuestionRequest, dict]): + The request object. The request for a QaQuestion. + name (str): + Required. The name of the QaQuestion + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaQuestion: + A single question to be scored by the + Insights QA feature. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetQaQuestionRequest): + request = contact_center_insights.GetQaQuestionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_qa_question] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_qa_question( + self, + request: Optional[ + Union[contact_center_insights.UpdateQaQuestionRequest, dict] + ] = None, + *, + qa_question: Optional[resources.QaQuestion] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaQuestion: + r"""Updates a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaQuestionRequest( + ) + + # Make the request + response = client.update_qa_question(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateQaQuestionRequest, dict]): + The request object. The request for updating a + QaQuestion. + qa_question (google.cloud.contact_center_insights_v1.types.QaQuestion): + Required. The QaQuestion to update. + This corresponds to the ``qa_question`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. All possible + fields can be updated by passing ``*``, or a subset of + the following updateable fields can be provided: + + - ``abbreviation`` + - ``answer_choices`` + - ``answer_instructions`` + - ``order`` + - ``question_body`` + - ``tags`` + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaQuestion: + A single question to be scored by the + Insights QA feature. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([qa_question, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateQaQuestionRequest): + request = contact_center_insights.UpdateQaQuestionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if qa_question is not None: + request.qa_question = qa_question + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_qa_question] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("qa_question.name", request.qa_question.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_qa_question( + self, + request: Optional[ + Union[contact_center_insights.DeleteQaQuestionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a QaQuestion. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaQuestionRequest( + name="name_value", + ) + + # Make the request + client.delete_qa_question(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteQaQuestionRequest, dict]): + The request object. The request for deleting a + QaQuestion. + name (str): + Required. The name of the QaQuestion + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteQaQuestionRequest): + request = contact_center_insights.DeleteQaQuestionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_qa_question] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_qa_questions( + self, + request: Optional[ + Union[contact_center_insights.ListQaQuestionsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQaQuestionsPager: + r"""Lists QaQuestions. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_qa_questions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaQuestionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_questions(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListQaQuestionsRequest, dict]): + The request object. Request to list QaQuestions. + parent (str): + Required. The parent resource of the + questions. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaQuestionsPager: + The response from a ListQaQuestions + request. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListQaQuestionsRequest): + request = contact_center_insights.ListQaQuestionsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_qa_questions] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListQaQuestionsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.CreateQaScorecardRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + qa_scorecard: Optional[resources.QaScorecard] = None, + qa_scorecard_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecard: + r"""Create a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_qa_scorecard(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateQaScorecardRequest, dict]): + The request object. The request for creating a + QaScorecard. + parent (str): + Required. The parent resource of the + QaScorecard. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard (google.cloud.contact_center_insights_v1.types.QaScorecard): + Required. The QaScorecard to create. + This corresponds to the ``qa_scorecard`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard_id (str): + Optional. A unique ID for the new QaScorecard. This ID + will become the final component of the QaScorecard's + resource name. If no ID is specified, a server-generated + ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-``. + + This corresponds to the ``qa_scorecard_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, qa_scorecard, qa_scorecard_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.CreateQaScorecardRequest): + request = contact_center_insights.CreateQaScorecardRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if qa_scorecard is not None: + request.qa_scorecard = qa_scorecard + if qa_scorecard_id is not None: + request.qa_scorecard_id = qa_scorecard_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_qa_scorecard] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.GetQaScorecardRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecard: + r"""Gets a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRequest( + name="name_value", + ) + + # Make the request + response = client.get_qa_scorecard(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetQaScorecardRequest, dict]): + The request object. The request for a QaScorecard. By + default, returns the latest revision. + name (str): + Required. The name of the QaScorecard + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetQaScorecardRequest): + request = contact_center_insights.GetQaScorecardRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_qa_scorecard] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.UpdateQaScorecardRequest, dict] + ] = None, + *, + qa_scorecard: Optional[resources.QaScorecard] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecard: + r"""Updates a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaScorecardRequest( + ) + + # Make the request + response = client.update_qa_scorecard(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateQaScorecardRequest, dict]): + The request object. The request for updating a + QaScorecard. + qa_scorecard (google.cloud.contact_center_insights_v1.types.QaScorecard): + Required. The QaScorecard to update. + This corresponds to the ``qa_scorecard`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. All possible + fields can be updated by passing ``*``, or a subset of + the following updateable fields can be provided: + + - ``description`` + - ``display_name`` + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([qa_scorecard, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.UpdateQaScorecardRequest): + request = contact_center_insights.UpdateQaScorecardRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if qa_scorecard is not None: + request.qa_scorecard = qa_scorecard + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_qa_scorecard] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("qa_scorecard.name", request.qa_scorecard.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_qa_scorecard( + self, + request: Optional[ + Union[contact_center_insights.DeleteQaScorecardRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRequest( + name="name_value", + ) + + # Make the request + client.delete_qa_scorecard(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRequest, dict]): + The request object. The request for deleting a + QaScorecard. + name (str): + Required. The name of the QaScorecard + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteQaScorecardRequest): + request = contact_center_insights.DeleteQaScorecardRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_qa_scorecard] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_qa_scorecards( + self, + request: Optional[ + Union[contact_center_insights.ListQaScorecardsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQaScorecardsPager: + r"""Lists QaScorecards. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_qa_scorecards(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecards(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListQaScorecardsRequest, dict]): + The request object. Request to list QaScorecards. + parent (str): + Required. The parent resource of the + scorecards. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardsPager: + The response from a ListQaScorecards + request. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListQaScorecardsRequest): + request = contact_center_insights.ListQaScorecardsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_qa_scorecards] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListQaScorecardsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.CreateQaScorecardRevisionRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + qa_scorecard_revision: Optional[resources.QaScorecardRevision] = None, + qa_scorecard_revision_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Creates a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRevisionRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateQaScorecardRevisionRequest, dict]): + The request object. The request for creating a + QaScorecardRevision. + parent (str): + Required. The parent resource of the + QaScorecardRevision. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard_revision (google.cloud.contact_center_insights_v1.types.QaScorecardRevision): + Required. The QaScorecardRevision to + create. + + This corresponds to the ``qa_scorecard_revision`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + qa_scorecard_revision_id (str): + Optional. A unique ID for the new QaScorecardRevision. + This ID will become the final component of the + QaScorecardRevision's resource name. If no ID is + specified, a server-generated ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-``. + + This corresponds to the ``qa_scorecard_revision_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [parent, qa_scorecard_revision, qa_scorecard_revision_id] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.CreateQaScorecardRevisionRequest + ): + request = contact_center_insights.CreateQaScorecardRevisionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if qa_scorecard_revision is not None: + request.qa_scorecard_revision = qa_scorecard_revision + if qa_scorecard_revision_id is not None: + request.qa_scorecard_revision_id = qa_scorecard_revision_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.create_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.GetQaScorecardRevisionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Gets a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.get_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetQaScorecardRevisionRequest, dict]): + The request object. The request for a + QaScorecardRevision. + name (str): + Required. The name of the + QaScorecardRevision to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.GetQaScorecardRevisionRequest + ): + request = contact_center_insights.GetQaScorecardRevisionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.get_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def tune_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.TuneQaScorecardRevisionRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + filter: Optional[str] = None, + validate_only: Optional[bool] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Fine tune one or more QaModels. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_tune_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.TuneQaScorecardRevisionRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + operation = client.tune_qa_scorecard_revision(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionRequest, dict]): + The request object. Request for TuneQaScorecardRevision + endpoint. + parent (str): + Required. The parent resource for new + fine tuning job instance. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (str): + Required. Filter for selecting the + feedback labels that needs to be used + for training. This filter can be used to + limit the feedback labels used for + tuning to a feedback labels created or + updated for a specific time-window etc. + + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + validate_only (bool): + Optional. Run in validate only mode, + no fine tuning will actually run. Data + quality validations like training data + distributions will run. Even when set to + false, the data quality validations will + still run but once the validations + complete we will proceed with the fine + tune, if applicable. + + This corresponds to the ``validate_only`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionResponse` + Response for TuneQaScorecardRevision endpoint. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, filter, validate_only]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.TuneQaScorecardRevisionRequest + ): + request = contact_center_insights.TuneQaScorecardRevisionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + if validate_only is not None: + request.validate_only = validate_only + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.tune_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.TuneQaScorecardRevisionResponse, + metadata_type=contact_center_insights.TuneQaScorecardRevisionMetadata, + ) + + # Done; return the response. + return response + + def deploy_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.DeployQaScorecardRevisionRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Deploy a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_deploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.deploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeployQaScorecardRevisionRequest, dict]): + The request object. The request to deploy a + QaScorecardRevision + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.DeployQaScorecardRevisionRequest + ): + request = contact_center_insights.DeployQaScorecardRevisionRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.deploy_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def undeploy_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.UndeployQaScorecardRevisionRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Undeploy a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_undeploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.undeploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UndeployQaScorecardRevisionRequest, dict]): + The request object. The request to undeploy a + QaScorecardRevision + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.UndeployQaScorecardRevisionRequest + ): + request = contact_center_insights.UndeployQaScorecardRevisionRequest( + request + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.undeploy_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_qa_scorecard_revision( + self, + request: Optional[ + Union[contact_center_insights.DeleteQaScorecardRevisionRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a QaScorecardRevision. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + client.delete_qa_scorecard_revision(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRevisionRequest, dict]): + The request object. The request to delete a + QaScorecardRevision. + name (str): + Required. The name of the + QaScorecardRevision to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.DeleteQaScorecardRevisionRequest + ): + request = contact_center_insights.DeleteQaScorecardRevisionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.delete_qa_scorecard_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_qa_scorecard_revisions( + self, + request: Optional[ + Union[contact_center_insights.ListQaScorecardRevisionsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQaScorecardRevisionsPager: + r"""Lists all revisions under the parent QaScorecard. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_qa_scorecard_revisions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecard_revisions(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsRequest, dict]): + The request object. Request to list QaScorecardRevisions + parent (str): + Required. The parent resource of the + scorecard revisions. To list all + revisions of all scorecards, substitute + the QaScorecard ID with a '-' character. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardRevisionsPager: + The response from a + ListQaScorecardRevisions request. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, contact_center_insights.ListQaScorecardRevisionsRequest + ): + request = contact_center_insights.ListQaScorecardRevisionsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.list_qa_scorecard_revisions + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListQaScorecardRevisionsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_feedback_label( + self, + request: Optional[ + Union[contact_center_insights.CreateFeedbackLabelRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + feedback_label: Optional[resources.FeedbackLabel] = None, + feedback_label_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FeedbackLabel: + r"""Create feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.CreateFeedbackLabelRequest( + parent="parent_value", + feedback_label=feedback_label, + ) + + # Make the request + response = client.create_feedback_label(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateFeedbackLabelRequest, dict]): + The request object. The request for creating a feedback + label. + parent (str): + Required. The parent resource of the + feedback label. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feedback_label (google.cloud.contact_center_insights_v1.types.FeedbackLabel): + Required. The feedback label to + create. + + This corresponds to the ``feedback_label`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + feedback_label_id (str): + Optional. The ID of the feedback + label to create. If one is not specified + it will be generated by the server. + + This corresponds to the ``feedback_label_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, feedback_label, feedback_label_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.CreateFeedbackLabelRequest): + request = contact_center_insights.CreateFeedbackLabelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if feedback_label is not None: + request.feedback_label = feedback_label + if feedback_label_id is not None: + request.feedback_label_id = feedback_label_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_feedback_label] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_feedback_labels( + self, + request: Optional[ + Union[contact_center_insights.ListFeedbackLabelsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFeedbackLabelsPager: + r"""List feedback labels. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListFeedbackLabelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_feedback_labels(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsRequest, dict]): + The request object. The request for listing feedback + labels. + parent (str): + Required. The parent resource of the + feedback labels. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListFeedbackLabelsPager: + The response for listing feedback + labels. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.ListFeedbackLabelsRequest): + request = contact_center_insights.ListFeedbackLabelsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_feedback_labels] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListFeedbackLabelsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_feedback_label( + self, + request: Optional[ + Union[contact_center_insights.GetFeedbackLabelRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FeedbackLabel: + r"""Get feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + response = client.get_feedback_label(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetFeedbackLabelRequest, dict]): + The request object. The request for getting a feedback + label. + name (str): + Required. The name of the feedback + label to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.GetFeedbackLabelRequest): + request = contact_center_insights.GetFeedbackLabelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_feedback_label] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_feedback_label( + self, + request: Optional[ + Union[contact_center_insights.UpdateFeedbackLabelRequest, dict] + ] = None, + *, + feedback_label: Optional[resources.FeedbackLabel] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FeedbackLabel: + r"""Update feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.UpdateFeedbackLabelRequest( + feedback_label=feedback_label, + ) + + # Make the request + response = client.update_feedback_label(request=request) + + # Handle the response + print(response) - This corresponds to the ``name`` field + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateFeedbackLabelRequest, dict]): + The request object. The request for updating a feedback + label. + feedback_label (google.cloud.contact_center_insights_v1.types.FeedbackLabel): + Required. The feedback label to + update. + + This corresponds to the ``feedback_label`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be + updated. + + This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -5396,13 +8964,15 @@ def sample_get_view(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. + google.cloud.contact_center_insights_v1.types.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) + has_flattened_params = any([feedback_label, update_mask]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5411,21 +8981,25 @@ def sample_get_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.GetViewRequest): - request = contact_center_insights.GetViewRequest(request) + if not isinstance(request, contact_center_insights.UpdateFeedbackLabelRequest): + request = contact_center_insights.UpdateFeedbackLabelRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if feedback_label is not None: + request.feedback_label = feedback_label + if update_mask is not None: + request.update_mask = update_mask # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_view] + rpc = self._transport._wrapped_methods[self._transport.update_feedback_label] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata( + (("feedback_label.name", request.feedback_label.name),) + ), ) # Validate the universe domain. @@ -5442,16 +9016,111 @@ def sample_get_view(): # Done; return the response. return response - def list_views( + def delete_feedback_label( self, - request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, + request: Optional[ + Union[contact_center_insights.DeleteFeedbackLabelRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Delete feedback label. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + client.delete_feedback_label(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteFeedbackLabelRequest, dict]): + The request object. The request for deleting a feedback + label. + name (str): + Required. The name of the feedback + label to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, contact_center_insights.DeleteFeedbackLabelRequest): + request = contact_center_insights.DeleteFeedbackLabelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_feedback_label] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_all_feedback_labels( + self, + request: Optional[ + Union[contact_center_insights.ListAllFeedbackLabelsRequest, dict] + ] = None, *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListViewsPager: - r"""Lists views. + ) -> pagers.ListAllFeedbackLabelsPager: + r"""List all feedback labels by project number. .. code-block:: python @@ -5464,28 +9133,29 @@ def list_views( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - def sample_list_views(): + def sample_list_all_feedback_labels(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsClient() # Initialize request argument(s) - request = contact_center_insights_v1.ListViewsRequest( + request = contact_center_insights_v1.ListAllFeedbackLabelsRequest( parent="parent_value", ) # Make the request - page_result = client.list_views(request=request) + page_result = client.list_all_feedback_labels(request=request) # Handle the response for response in page_result: print(response) Args: - request (Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]): - The request object. The request to list views. + request (Union[google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsRequest, dict]): + The request object. The request for listing all feedback + labels. parent (str): - Required. The parent resource of the - views. + Required. The parent resource of all + feedback labels per project. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -5497,9 +9167,9 @@ def sample_list_views(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager: - The response of listing views. - + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAllFeedbackLabelsPager: + The response for listing all feedback + labels. Iterating over this object will yield results and resolve additional pages automatically. @@ -5517,8 +9187,10 @@ def sample_list_views(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.ListViewsRequest): - request = contact_center_insights.ListViewsRequest(request) + if not isinstance( + request, contact_center_insights.ListAllFeedbackLabelsRequest + ): + request = contact_center_insights.ListAllFeedbackLabelsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: @@ -5526,7 +9198,7 @@ def sample_list_views(): # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_views] + rpc = self._transport._wrapped_methods[self._transport.list_all_feedback_labels] # Certain fields should be provided within the metadata header; # add these here. @@ -5547,7 +9219,7 @@ def sample_list_views(): # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. - response = pagers.ListViewsPager( + response = pagers.ListAllFeedbackLabelsPager( method=rpc, request=request, response=response, @@ -5559,19 +9231,18 @@ def sample_list_views(): # Done; return the response. return response - def update_view( + def bulk_upload_feedback_labels( self, request: Optional[ - Union[contact_center_insights.UpdateViewRequest, dict] + Union[contact_center_insights.BulkUploadFeedbackLabelsRequest, dict] ] = None, *, - view: Optional[resources.View] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Updates a view. + ) -> operation.Operation: + r"""Upload feedback labels in bulk. .. code-block:: python @@ -5584,31 +9255,39 @@ def update_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - def sample_update_view(): + def sample_bulk_upload_feedback_labels(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsClient() # Initialize request argument(s) - request = contact_center_insights_v1.UpdateViewRequest( + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.format_ = "JSON" + gcs_source.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkUploadFeedbackLabelsRequest( + gcs_source=gcs_source, + parent="parent_value", ) # Make the request - response = client.update_view(request=request) + operation = client.bulk_upload_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() # Handle the response print(response) Args: - request (Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]): - The request object. The request to update a view. - view (google.cloud.contact_center_insights_v1.types.View): - Required. The new view. - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - This corresponds to the ``update_mask`` field + request (Union[google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsRequest, dict]): + The request object. The request for bulk uploading + feedback labels. + parent (str): + Required. The parent resource for new + feedback labels. + + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -5618,13 +9297,18 @@ def sample_update_view(): sent along with the request as metadata. Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsResponse` + Response for the Bulk Upload Feedback Labels API. + """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([view, update_mask]) + has_flattened_params = any([parent]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5633,25 +9317,25 @@ def sample_update_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.UpdateViewRequest): - request = contact_center_insights.UpdateViewRequest(request) + if not isinstance( + request, contact_center_insights.BulkUploadFeedbackLabelsRequest + ): + request = contact_center_insights.BulkUploadFeedbackLabelsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if view is not None: - request.view = view - if update_mask is not None: - request.update_mask = update_mask + if parent is not None: + request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_view] + rpc = self._transport._wrapped_methods[ + self._transport.bulk_upload_feedback_labels + ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("view.name", request.view.name),) - ), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -5665,21 +9349,29 @@ def sample_update_view(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.BulkUploadFeedbackLabelsResponse, + metadata_type=contact_center_insights.BulkUploadFeedbackLabelsMetadata, + ) + # Done; return the response. return response - def delete_view( + def bulk_download_feedback_labels( self, request: Optional[ - Union[contact_center_insights.DeleteViewRequest, dict] + Union[contact_center_insights.BulkDownloadFeedbackLabelsRequest, dict] ] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a view. + ) -> operation.Operation: + r"""Download feedback labels in bulk. .. code-block:: python @@ -5692,26 +9384,39 @@ def delete_view( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import contact_center_insights_v1 - def sample_delete_view(): + def sample_bulk_download_feedback_labels(): # Create a client client = contact_center_insights_v1.ContactCenterInsightsClient() # Initialize request argument(s) - request = contact_center_insights_v1.DeleteViewRequest( - name="name_value", + gcs_destination = contact_center_insights_v1.GcsDestination() + gcs_destination.format_ = "JSON" + gcs_destination.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkDownloadFeedbackLabelsRequest( + gcs_destination=gcs_destination, + parent="parent_value", ) # Make the request - client.delete_view(request=request) + operation = client.bulk_download_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]): - The request object. The request to delete a view. - name (str): - Required. The name of the view to - delete. + request (Union[google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest, dict]): + The request object. Request for the + BulkDownloadFeedbackLabel endpoint. + parent (str): + Required. The parent resource for new + feedback labels. - This corresponds to the ``name`` field + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -5719,11 +9424,20 @@ def sample_delete_view(): timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsResponse` + Response for the BulkDownloadFeedbackLabel endpoint. + """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) + has_flattened_params = any([parent]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -5732,34 +9446,49 @@ def sample_delete_view(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, contact_center_insights.DeleteViewRequest): - request = contact_center_insights.DeleteViewRequest(request) + if not isinstance( + request, contact_center_insights.BulkDownloadFeedbackLabelsRequest + ): + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_view] + rpc = self._transport._wrapped_methods[ + self._transport.bulk_download_feedback_labels + ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. - rpc( + response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.BulkDownloadFeedbackLabelsResponse, + metadata_type=contact_center_insights.BulkDownloadFeedbackLabelsMetadata, + ) + + # Done; return the response. + return response + def __enter__(self) -> "ContactCenterInsightsClient": return self diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py index 4365a6e18ee3..cc9dcc2e7973 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py @@ -510,6 +510,162 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class ListAnalysisRulesPager: + """A pager for iterating through ``list_analysis_rules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAnalysisRulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``analysis_rules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAnalysisRules`` requests and continue to iterate + through the ``analysis_rules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysisRulesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., contact_center_insights.ListAnalysisRulesResponse], + request: contact_center_insights.ListAnalysisRulesRequest, + response: contact_center_insights.ListAnalysisRulesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListAnalysisRulesRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAnalysisRulesResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListAnalysisRulesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListAnalysisRulesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[resources.AnalysisRule]: + for page in self.pages: + yield from page.analysis_rules + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAnalysisRulesAsyncPager: + """A pager for iterating through ``list_analysis_rules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAnalysisRulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``analysis_rules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAnalysisRules`` requests and continue to iterate + through the ``analysis_rules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysisRulesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[contact_center_insights.ListAnalysisRulesResponse] + ], + request: contact_center_insights.ListAnalysisRulesRequest, + response: contact_center_insights.ListAnalysisRulesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListAnalysisRulesRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAnalysisRulesResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListAnalysisRulesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[contact_center_insights.ListAnalysisRulesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[resources.AnalysisRule]: + async def async_generator(): + async for page in self.pages: + for response in page.analysis_rules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListViewsPager: """A pager for iterating through ``list_views`` requests. @@ -660,3 +816,785 @@ async def async_generator(): def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListQaQuestionsPager: + """A pager for iterating through ``list_qa_questions`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListQaQuestionsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``qa_questions`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListQaQuestions`` requests and continue to iterate + through the ``qa_questions`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListQaQuestionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., contact_center_insights.ListQaQuestionsResponse], + request: contact_center_insights.ListQaQuestionsRequest, + response: contact_center_insights.ListQaQuestionsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListQaQuestionsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListQaQuestionsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListQaQuestionsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListQaQuestionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[resources.QaQuestion]: + for page in self.pages: + yield from page.qa_questions + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListQaQuestionsAsyncPager: + """A pager for iterating through ``list_qa_questions`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListQaQuestionsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``qa_questions`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListQaQuestions`` requests and continue to iterate + through the ``qa_questions`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListQaQuestionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[contact_center_insights.ListQaQuestionsResponse] + ], + request: contact_center_insights.ListQaQuestionsRequest, + response: contact_center_insights.ListQaQuestionsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListQaQuestionsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListQaQuestionsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListQaQuestionsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[contact_center_insights.ListQaQuestionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[resources.QaQuestion]: + async def async_generator(): + async for page in self.pages: + for response in page.qa_questions: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListQaScorecardsPager: + """A pager for iterating through ``list_qa_scorecards`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``qa_scorecards`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListQaScorecards`` requests and continue to iterate + through the ``qa_scorecards`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., contact_center_insights.ListQaScorecardsResponse], + request: contact_center_insights.ListQaScorecardsRequest, + response: contact_center_insights.ListQaScorecardsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListQaScorecardsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListQaScorecardsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListQaScorecardsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListQaScorecardsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[resources.QaScorecard]: + for page in self.pages: + yield from page.qa_scorecards + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListQaScorecardsAsyncPager: + """A pager for iterating through ``list_qa_scorecards`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``qa_scorecards`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListQaScorecards`` requests and continue to iterate + through the ``qa_scorecards`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[contact_center_insights.ListQaScorecardsResponse] + ], + request: contact_center_insights.ListQaScorecardsRequest, + response: contact_center_insights.ListQaScorecardsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListQaScorecardsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListQaScorecardsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListQaScorecardsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[contact_center_insights.ListQaScorecardsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[resources.QaScorecard]: + async def async_generator(): + async for page in self.pages: + for response in page.qa_scorecards: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListQaScorecardRevisionsPager: + """A pager for iterating through ``list_qa_scorecard_revisions`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``qa_scorecard_revisions`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListQaScorecardRevisions`` requests and continue to iterate + through the ``qa_scorecard_revisions`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., contact_center_insights.ListQaScorecardRevisionsResponse], + request: contact_center_insights.ListQaScorecardRevisionsRequest, + response: contact_center_insights.ListQaScorecardRevisionsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListQaScorecardRevisionsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages( + self, + ) -> Iterator[contact_center_insights.ListQaScorecardRevisionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[resources.QaScorecardRevision]: + for page in self.pages: + yield from page.qa_scorecard_revisions + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListQaScorecardRevisionsAsyncPager: + """A pager for iterating through ``list_qa_scorecard_revisions`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``qa_scorecard_revisions`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListQaScorecardRevisions`` requests and continue to iterate + through the ``qa_scorecard_revisions`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[contact_center_insights.ListQaScorecardRevisionsResponse] + ], + request: contact_center_insights.ListQaScorecardRevisionsRequest, + response: contact_center_insights.ListQaScorecardRevisionsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListQaScorecardRevisionsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[contact_center_insights.ListQaScorecardRevisionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[resources.QaScorecardRevision]: + async def async_generator(): + async for page in self.pages: + for response in page.qa_scorecard_revisions: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFeedbackLabelsPager: + """A pager for iterating through ``list_feedback_labels`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``feedback_labels`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFeedbackLabels`` requests and continue to iterate + through the ``feedback_labels`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., contact_center_insights.ListFeedbackLabelsResponse], + request: contact_center_insights.ListFeedbackLabelsRequest, + response: contact_center_insights.ListFeedbackLabelsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListFeedbackLabelsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListFeedbackLabelsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[resources.FeedbackLabel]: + for page in self.pages: + yield from page.feedback_labels + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFeedbackLabelsAsyncPager: + """A pager for iterating through ``list_feedback_labels`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``feedback_labels`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFeedbackLabels`` requests and continue to iterate + through the ``feedback_labels`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[contact_center_insights.ListFeedbackLabelsResponse] + ], + request: contact_center_insights.ListFeedbackLabelsRequest, + response: contact_center_insights.ListFeedbackLabelsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListFeedbackLabelsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[contact_center_insights.ListFeedbackLabelsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[resources.FeedbackLabel]: + async def async_generator(): + async for page in self.pages: + for response in page.feedback_labels: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAllFeedbackLabelsPager: + """A pager for iterating through ``list_all_feedback_labels`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``feedback_labels`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAllFeedbackLabels`` requests and continue to iterate + through the ``feedback_labels`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., contact_center_insights.ListAllFeedbackLabelsResponse], + request: contact_center_insights.ListAllFeedbackLabelsRequest, + response: contact_center_insights.ListAllFeedbackLabelsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListAllFeedbackLabelsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListAllFeedbackLabelsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[resources.FeedbackLabel]: + for page in self.pages: + yield from page.feedback_labels + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAllFeedbackLabelsAsyncPager: + """A pager for iterating through ``list_all_feedback_labels`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``feedback_labels`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAllFeedbackLabels`` requests and continue to iterate + through the ``feedback_labels`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[contact_center_insights.ListAllFeedbackLabelsResponse] + ], + request: contact_center_insights.ListAllFeedbackLabelsRequest, + response: contact_center_insights.ListAllFeedbackLabelsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListAllFeedbackLabelsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[contact_center_insights.ListAllFeedbackLabelsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[resources.FeedbackLabel]: + async def async_generator(): + async for page in self.pages: + for response in page.feedback_labels: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py index 31f056218a32..33958f8aa1c0 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py @@ -22,6 +22,8 @@ from google.api_core import retry as retries import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -313,6 +315,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_analysis_rule: gapic_v1.method.wrap_method( + self.create_analysis_rule, + default_timeout=None, + client_info=client_info, + ), + self.get_analysis_rule: gapic_v1.method.wrap_method( + self.get_analysis_rule, + default_timeout=None, + client_info=client_info, + ), + self.list_analysis_rules: gapic_v1.method.wrap_method( + self.list_analysis_rules, + default_timeout=None, + client_info=client_info, + ), + self.update_analysis_rule: gapic_v1.method.wrap_method( + self.update_analysis_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_analysis_rule: gapic_v1.method.wrap_method( + self.delete_analysis_rule, + default_timeout=None, + client_info=client_info, + ), self.get_encryption_spec: gapic_v1.method.wrap_method( self.get_encryption_spec, default_timeout=None, @@ -348,6 +375,136 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.query_metrics: gapic_v1.method.wrap_method( + self.query_metrics, + default_timeout=None, + client_info=client_info, + ), + self.create_qa_question: gapic_v1.method.wrap_method( + self.create_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.get_qa_question: gapic_v1.method.wrap_method( + self.get_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.update_qa_question: gapic_v1.method.wrap_method( + self.update_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.delete_qa_question: gapic_v1.method.wrap_method( + self.delete_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.list_qa_questions: gapic_v1.method.wrap_method( + self.list_qa_questions, + default_timeout=None, + client_info=client_info, + ), + self.create_qa_scorecard: gapic_v1.method.wrap_method( + self.create_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.get_qa_scorecard: gapic_v1.method.wrap_method( + self.get_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.update_qa_scorecard: gapic_v1.method.wrap_method( + self.update_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.delete_qa_scorecard: gapic_v1.method.wrap_method( + self.delete_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.list_qa_scorecards: gapic_v1.method.wrap_method( + self.list_qa_scorecards, + default_timeout=None, + client_info=client_info, + ), + self.create_qa_scorecard_revision: gapic_v1.method.wrap_method( + self.create_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.get_qa_scorecard_revision: gapic_v1.method.wrap_method( + self.get_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.tune_qa_scorecard_revision: gapic_v1.method.wrap_method( + self.tune_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.deploy_qa_scorecard_revision: gapic_v1.method.wrap_method( + self.deploy_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.undeploy_qa_scorecard_revision: gapic_v1.method.wrap_method( + self.undeploy_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.delete_qa_scorecard_revision: gapic_v1.method.wrap_method( + self.delete_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.list_qa_scorecard_revisions: gapic_v1.method.wrap_method( + self.list_qa_scorecard_revisions, + default_timeout=None, + client_info=client_info, + ), + self.create_feedback_label: gapic_v1.method.wrap_method( + self.create_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.list_feedback_labels: gapic_v1.method.wrap_method( + self.list_feedback_labels, + default_timeout=None, + client_info=client_info, + ), + self.get_feedback_label: gapic_v1.method.wrap_method( + self.get_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.update_feedback_label: gapic_v1.method.wrap_method( + self.update_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.delete_feedback_label: gapic_v1.method.wrap_method( + self.delete_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.list_all_feedback_labels: gapic_v1.method.wrap_method( + self.list_all_feedback_labels, + default_timeout=None, + client_info=client_info, + ), + self.bulk_upload_feedback_labels: gapic_v1.method.wrap_method( + self.bulk_upload_feedback_labels, + default_timeout=None, + client_info=client_info, + ), + self.bulk_download_feedback_labels: gapic_v1.method.wrap_method( + self.bulk_download_feedback_labels, + default_timeout=None, + client_info=client_info, + ), self.cancel_operation: gapic_v1.method.wrap_method( self.cancel_operation, default_timeout=None, @@ -724,6 +881,54 @@ def update_settings( ]: raise NotImplementedError() + @property + def create_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.CreateAnalysisRuleRequest], + Union[resources.AnalysisRule, Awaitable[resources.AnalysisRule]], + ]: + raise NotImplementedError() + + @property + def get_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.GetAnalysisRuleRequest], + Union[resources.AnalysisRule, Awaitable[resources.AnalysisRule]], + ]: + raise NotImplementedError() + + @property + def list_analysis_rules( + self, + ) -> Callable[ + [contact_center_insights.ListAnalysisRulesRequest], + Union[ + contact_center_insights.ListAnalysisRulesResponse, + Awaitable[contact_center_insights.ListAnalysisRulesResponse], + ], + ]: + raise NotImplementedError() + + @property + def update_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.UpdateAnalysisRuleRequest], + Union[resources.AnalysisRule, Awaitable[resources.AnalysisRule]], + ]: + raise NotImplementedError() + + @property + def delete_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.DeleteAnalysisRuleRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + @property def get_encryption_spec( self, @@ -790,6 +995,255 @@ def delete_view( ]: raise NotImplementedError() + @property + def query_metrics( + self, + ) -> Callable[ + [contact_center_insights.QueryMetricsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def create_qa_question( + self, + ) -> Callable[ + [contact_center_insights.CreateQaQuestionRequest], + Union[resources.QaQuestion, Awaitable[resources.QaQuestion]], + ]: + raise NotImplementedError() + + @property + def get_qa_question( + self, + ) -> Callable[ + [contact_center_insights.GetQaQuestionRequest], + Union[resources.QaQuestion, Awaitable[resources.QaQuestion]], + ]: + raise NotImplementedError() + + @property + def update_qa_question( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaQuestionRequest], + Union[resources.QaQuestion, Awaitable[resources.QaQuestion]], + ]: + raise NotImplementedError() + + @property + def delete_qa_question( + self, + ) -> Callable[ + [contact_center_insights.DeleteQaQuestionRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def list_qa_questions( + self, + ) -> Callable[ + [contact_center_insights.ListQaQuestionsRequest], + Union[ + contact_center_insights.ListQaQuestionsResponse, + Awaitable[contact_center_insights.ListQaQuestionsResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRequest], + Union[resources.QaScorecard, Awaitable[resources.QaScorecard]], + ]: + raise NotImplementedError() + + @property + def get_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRequest], + Union[resources.QaScorecard, Awaitable[resources.QaScorecard]], + ]: + raise NotImplementedError() + + @property + def update_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaScorecardRequest], + Union[resources.QaScorecard, Awaitable[resources.QaScorecard]], + ]: + raise NotImplementedError() + + @property + def delete_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.DeleteQaScorecardRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def list_qa_scorecards( + self, + ) -> Callable[ + [contact_center_insights.ListQaScorecardsRequest], + Union[ + contact_center_insights.ListQaScorecardsResponse, + Awaitable[contact_center_insights.ListQaScorecardsResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRevisionRequest], + Union[resources.QaScorecardRevision, Awaitable[resources.QaScorecardRevision]], + ]: + raise NotImplementedError() + + @property + def get_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRevisionRequest], + Union[resources.QaScorecardRevision, Awaitable[resources.QaScorecardRevision]], + ]: + raise NotImplementedError() + + @property + def tune_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.TuneQaScorecardRevisionRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def deploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.DeployQaScorecardRevisionRequest], + Union[resources.QaScorecardRevision, Awaitable[resources.QaScorecardRevision]], + ]: + raise NotImplementedError() + + @property + def undeploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.UndeployQaScorecardRevisionRequest], + Union[resources.QaScorecardRevision, Awaitable[resources.QaScorecardRevision]], + ]: + raise NotImplementedError() + + @property + def delete_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.DeleteQaScorecardRevisionRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def list_qa_scorecard_revisions( + self, + ) -> Callable[ + [contact_center_insights.ListQaScorecardRevisionsRequest], + Union[ + contact_center_insights.ListQaScorecardRevisionsResponse, + Awaitable[contact_center_insights.ListQaScorecardRevisionsResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.CreateFeedbackLabelRequest], + Union[resources.FeedbackLabel, Awaitable[resources.FeedbackLabel]], + ]: + raise NotImplementedError() + + @property + def list_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.ListFeedbackLabelsRequest], + Union[ + contact_center_insights.ListFeedbackLabelsResponse, + Awaitable[contact_center_insights.ListFeedbackLabelsResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.GetFeedbackLabelRequest], + Union[resources.FeedbackLabel, Awaitable[resources.FeedbackLabel]], + ]: + raise NotImplementedError() + + @property + def update_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.UpdateFeedbackLabelRequest], + Union[resources.FeedbackLabel, Awaitable[resources.FeedbackLabel]], + ]: + raise NotImplementedError() + + @property + def delete_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.DeleteFeedbackLabelRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def list_all_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.ListAllFeedbackLabelsRequest], + Union[ + contact_center_insights.ListAllFeedbackLabelsResponse, + Awaitable[contact_center_insights.ListAllFeedbackLabelsResponse], + ], + ]: + raise NotImplementedError() + + @property + def bulk_upload_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkUploadFeedbackLabelsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def bulk_download_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkDownloadFeedbackLabelsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def list_operations( self, diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py index adb2ad6f700c..7f4df2d42283 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py @@ -20,6 +20,8 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -1265,6 +1267,145 @@ def update_settings( ) return self._stubs["update_settings"] + @property + def create_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.CreateAnalysisRuleRequest], resources.AnalysisRule + ]: + r"""Return a callable for the create analysis rule method over gRPC. + + Creates a analysis rule. + + Returns: + Callable[[~.CreateAnalysisRuleRequest], + ~.AnalysisRule]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_analysis_rule" not in self._stubs: + self._stubs["create_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysisRule", + request_serializer=contact_center_insights.CreateAnalysisRuleRequest.serialize, + response_deserializer=resources.AnalysisRule.deserialize, + ) + return self._stubs["create_analysis_rule"] + + @property + def get_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.GetAnalysisRuleRequest], resources.AnalysisRule + ]: + r"""Return a callable for the get analysis rule method over gRPC. + + Get a analysis rule. + + Returns: + Callable[[~.GetAnalysisRuleRequest], + ~.AnalysisRule]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_analysis_rule" not in self._stubs: + self._stubs["get_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysisRule", + request_serializer=contact_center_insights.GetAnalysisRuleRequest.serialize, + response_deserializer=resources.AnalysisRule.deserialize, + ) + return self._stubs["get_analysis_rule"] + + @property + def list_analysis_rules( + self, + ) -> Callable[ + [contact_center_insights.ListAnalysisRulesRequest], + contact_center_insights.ListAnalysisRulesResponse, + ]: + r"""Return a callable for the list analysis rules method over gRPC. + + Lists analysis rules. + + Returns: + Callable[[~.ListAnalysisRulesRequest], + ~.ListAnalysisRulesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_analysis_rules" not in self._stubs: + self._stubs["list_analysis_rules"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalysisRules", + request_serializer=contact_center_insights.ListAnalysisRulesRequest.serialize, + response_deserializer=contact_center_insights.ListAnalysisRulesResponse.deserialize, + ) + return self._stubs["list_analysis_rules"] + + @property + def update_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.UpdateAnalysisRuleRequest], resources.AnalysisRule + ]: + r"""Return a callable for the update analysis rule method over gRPC. + + Updates a analysis rule. + + Returns: + Callable[[~.UpdateAnalysisRuleRequest], + ~.AnalysisRule]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_analysis_rule" not in self._stubs: + self._stubs["update_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateAnalysisRule", + request_serializer=contact_center_insights.UpdateAnalysisRuleRequest.serialize, + response_deserializer=resources.AnalysisRule.deserialize, + ) + return self._stubs["update_analysis_rule"] + + @property + def delete_analysis_rule( + self, + ) -> Callable[[contact_center_insights.DeleteAnalysisRuleRequest], empty_pb2.Empty]: + r"""Return a callable for the delete analysis rule method over gRPC. + + Deletes a analysis rule. + + Returns: + Callable[[~.DeleteAnalysisRuleRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_analysis_rule" not in self._stubs: + self._stubs["delete_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysisRule", + request_serializer=contact_center_insights.DeleteAnalysisRuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_analysis_rule"] + @property def get_encryption_spec( self, @@ -1303,9 +1444,9 @@ def initialize_encryption_spec( r"""Return a callable for the initialize encryption spec method over gRPC. Initializes a location-level encryption key - specification. An error will be thrown if the location - has resources already created before the initialization. - Once the encryption specification is initialized at a + specification. An error will result if the location has + resources already created before the initialization. + After the encryption specification is initialized at a location, it is immutable and all newly created resources under the location will be encrypted with the existing specification. @@ -1461,6 +1602,744 @@ def delete_view( ) return self._stubs["delete_view"] + @property + def query_metrics( + self, + ) -> Callable[ + [contact_center_insights.QueryMetricsRequest], operations_pb2.Operation + ]: + r"""Return a callable for the query metrics method over gRPC. + + Query metrics. + + Returns: + Callable[[~.QueryMetricsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "query_metrics" not in self._stubs: + self._stubs["query_metrics"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/QueryMetrics", + request_serializer=contact_center_insights.QueryMetricsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["query_metrics"] + + @property + def create_qa_question( + self, + ) -> Callable[ + [contact_center_insights.CreateQaQuestionRequest], resources.QaQuestion + ]: + r"""Return a callable for the create qa question method over gRPC. + + Create a QaQuestion. + + Returns: + Callable[[~.CreateQaQuestionRequest], + ~.QaQuestion]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_qa_question" not in self._stubs: + self._stubs["create_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateQaQuestion", + request_serializer=contact_center_insights.CreateQaQuestionRequest.serialize, + response_deserializer=resources.QaQuestion.deserialize, + ) + return self._stubs["create_qa_question"] + + @property + def get_qa_question( + self, + ) -> Callable[[contact_center_insights.GetQaQuestionRequest], resources.QaQuestion]: + r"""Return a callable for the get qa question method over gRPC. + + Gets a QaQuestion. + + Returns: + Callable[[~.GetQaQuestionRequest], + ~.QaQuestion]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_qa_question" not in self._stubs: + self._stubs["get_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetQaQuestion", + request_serializer=contact_center_insights.GetQaQuestionRequest.serialize, + response_deserializer=resources.QaQuestion.deserialize, + ) + return self._stubs["get_qa_question"] + + @property + def update_qa_question( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaQuestionRequest], resources.QaQuestion + ]: + r"""Return a callable for the update qa question method over gRPC. + + Updates a QaQuestion. + + Returns: + Callable[[~.UpdateQaQuestionRequest], + ~.QaQuestion]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_qa_question" not in self._stubs: + self._stubs["update_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateQaQuestion", + request_serializer=contact_center_insights.UpdateQaQuestionRequest.serialize, + response_deserializer=resources.QaQuestion.deserialize, + ) + return self._stubs["update_qa_question"] + + @property + def delete_qa_question( + self, + ) -> Callable[[contact_center_insights.DeleteQaQuestionRequest], empty_pb2.Empty]: + r"""Return a callable for the delete qa question method over gRPC. + + Deletes a QaQuestion. + + Returns: + Callable[[~.DeleteQaQuestionRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_qa_question" not in self._stubs: + self._stubs["delete_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteQaQuestion", + request_serializer=contact_center_insights.DeleteQaQuestionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_qa_question"] + + @property + def list_qa_questions( + self, + ) -> Callable[ + [contact_center_insights.ListQaQuestionsRequest], + contact_center_insights.ListQaQuestionsResponse, + ]: + r"""Return a callable for the list qa questions method over gRPC. + + Lists QaQuestions. + + Returns: + Callable[[~.ListQaQuestionsRequest], + ~.ListQaQuestionsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_qa_questions" not in self._stubs: + self._stubs["list_qa_questions"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListQaQuestions", + request_serializer=contact_center_insights.ListQaQuestionsRequest.serialize, + response_deserializer=contact_center_insights.ListQaQuestionsResponse.deserialize, + ) + return self._stubs["list_qa_questions"] + + @property + def create_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRequest], resources.QaScorecard + ]: + r"""Return a callable for the create qa scorecard method over gRPC. + + Create a QaScorecard. + + Returns: + Callable[[~.CreateQaScorecardRequest], + ~.QaScorecard]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_qa_scorecard" not in self._stubs: + self._stubs["create_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateQaScorecard", + request_serializer=contact_center_insights.CreateQaScorecardRequest.serialize, + response_deserializer=resources.QaScorecard.deserialize, + ) + return self._stubs["create_qa_scorecard"] + + @property + def get_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRequest], resources.QaScorecard + ]: + r"""Return a callable for the get qa scorecard method over gRPC. + + Gets a QaScorecard. + + Returns: + Callable[[~.GetQaScorecardRequest], + ~.QaScorecard]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_qa_scorecard" not in self._stubs: + self._stubs["get_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetQaScorecard", + request_serializer=contact_center_insights.GetQaScorecardRequest.serialize, + response_deserializer=resources.QaScorecard.deserialize, + ) + return self._stubs["get_qa_scorecard"] + + @property + def update_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaScorecardRequest], resources.QaScorecard + ]: + r"""Return a callable for the update qa scorecard method over gRPC. + + Updates a QaScorecard. + + Returns: + Callable[[~.UpdateQaScorecardRequest], + ~.QaScorecard]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_qa_scorecard" not in self._stubs: + self._stubs["update_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateQaScorecard", + request_serializer=contact_center_insights.UpdateQaScorecardRequest.serialize, + response_deserializer=resources.QaScorecard.deserialize, + ) + return self._stubs["update_qa_scorecard"] + + @property + def delete_qa_scorecard( + self, + ) -> Callable[[contact_center_insights.DeleteQaScorecardRequest], empty_pb2.Empty]: + r"""Return a callable for the delete qa scorecard method over gRPC. + + Deletes a QaScorecard. + + Returns: + Callable[[~.DeleteQaScorecardRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_qa_scorecard" not in self._stubs: + self._stubs["delete_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteQaScorecard", + request_serializer=contact_center_insights.DeleteQaScorecardRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_qa_scorecard"] + + @property + def list_qa_scorecards( + self, + ) -> Callable[ + [contact_center_insights.ListQaScorecardsRequest], + contact_center_insights.ListQaScorecardsResponse, + ]: + r"""Return a callable for the list qa scorecards method over gRPC. + + Lists QaScorecards. + + Returns: + Callable[[~.ListQaScorecardsRequest], + ~.ListQaScorecardsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_qa_scorecards" not in self._stubs: + self._stubs["list_qa_scorecards"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListQaScorecards", + request_serializer=contact_center_insights.ListQaScorecardsRequest.serialize, + response_deserializer=contact_center_insights.ListQaScorecardsResponse.deserialize, + ) + return self._stubs["list_qa_scorecards"] + + @property + def create_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + r"""Return a callable for the create qa scorecard revision method over gRPC. + + Creates a QaScorecardRevision. + + Returns: + Callable[[~.CreateQaScorecardRevisionRequest], + ~.QaScorecardRevision]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_qa_scorecard_revision" not in self._stubs: + self._stubs["create_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateQaScorecardRevision", + request_serializer=contact_center_insights.CreateQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, + ) + return self._stubs["create_qa_scorecard_revision"] + + @property + def get_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + r"""Return a callable for the get qa scorecard revision method over gRPC. + + Gets a QaScorecardRevision. + + Returns: + Callable[[~.GetQaScorecardRevisionRequest], + ~.QaScorecardRevision]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_qa_scorecard_revision" not in self._stubs: + self._stubs["get_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetQaScorecardRevision", + request_serializer=contact_center_insights.GetQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, + ) + return self._stubs["get_qa_scorecard_revision"] + + @property + def tune_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.TuneQaScorecardRevisionRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the tune qa scorecard revision method over gRPC. + + Fine tune one or more QaModels. + + Returns: + Callable[[~.TuneQaScorecardRevisionRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "tune_qa_scorecard_revision" not in self._stubs: + self._stubs["tune_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/TuneQaScorecardRevision", + request_serializer=contact_center_insights.TuneQaScorecardRevisionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["tune_qa_scorecard_revision"] + + @property + def deploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.DeployQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + r"""Return a callable for the deploy qa scorecard revision method over gRPC. + + Deploy a QaScorecardRevision. + + Returns: + Callable[[~.DeployQaScorecardRevisionRequest], + ~.QaScorecardRevision]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "deploy_qa_scorecard_revision" not in self._stubs: + self._stubs["deploy_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployQaScorecardRevision", + request_serializer=contact_center_insights.DeployQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, + ) + return self._stubs["deploy_qa_scorecard_revision"] + + @property + def undeploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.UndeployQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + r"""Return a callable for the undeploy qa scorecard revision method over gRPC. + + Undeploy a QaScorecardRevision. + + Returns: + Callable[[~.UndeployQaScorecardRevisionRequest], + ~.QaScorecardRevision]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "undeploy_qa_scorecard_revision" not in self._stubs: + self._stubs[ + "undeploy_qa_scorecard_revision" + ] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployQaScorecardRevision", + request_serializer=contact_center_insights.UndeployQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, + ) + return self._stubs["undeploy_qa_scorecard_revision"] + + @property + def delete_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.DeleteQaScorecardRevisionRequest], empty_pb2.Empty + ]: + r"""Return a callable for the delete qa scorecard revision method over gRPC. + + Deletes a QaScorecardRevision. + + Returns: + Callable[[~.DeleteQaScorecardRevisionRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_qa_scorecard_revision" not in self._stubs: + self._stubs["delete_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteQaScorecardRevision", + request_serializer=contact_center_insights.DeleteQaScorecardRevisionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_qa_scorecard_revision"] + + @property + def list_qa_scorecard_revisions( + self, + ) -> Callable[ + [contact_center_insights.ListQaScorecardRevisionsRequest], + contact_center_insights.ListQaScorecardRevisionsResponse, + ]: + r"""Return a callable for the list qa scorecard revisions method over gRPC. + + Lists all revisions under the parent QaScorecard. + + Returns: + Callable[[~.ListQaScorecardRevisionsRequest], + ~.ListQaScorecardRevisionsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_qa_scorecard_revisions" not in self._stubs: + self._stubs["list_qa_scorecard_revisions"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListQaScorecardRevisions", + request_serializer=contact_center_insights.ListQaScorecardRevisionsRequest.serialize, + response_deserializer=contact_center_insights.ListQaScorecardRevisionsResponse.deserialize, + ) + return self._stubs["list_qa_scorecard_revisions"] + + @property + def create_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.CreateFeedbackLabelRequest], resources.FeedbackLabel + ]: + r"""Return a callable for the create feedback label method over gRPC. + + Create feedback label. + + Returns: + Callable[[~.CreateFeedbackLabelRequest], + ~.FeedbackLabel]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_feedback_label" not in self._stubs: + self._stubs["create_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateFeedbackLabel", + request_serializer=contact_center_insights.CreateFeedbackLabelRequest.serialize, + response_deserializer=resources.FeedbackLabel.deserialize, + ) + return self._stubs["create_feedback_label"] + + @property + def list_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.ListFeedbackLabelsRequest], + contact_center_insights.ListFeedbackLabelsResponse, + ]: + r"""Return a callable for the list feedback labels method over gRPC. + + List feedback labels. + + Returns: + Callable[[~.ListFeedbackLabelsRequest], + ~.ListFeedbackLabelsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_feedback_labels" not in self._stubs: + self._stubs["list_feedback_labels"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListFeedbackLabels", + request_serializer=contact_center_insights.ListFeedbackLabelsRequest.serialize, + response_deserializer=contact_center_insights.ListFeedbackLabelsResponse.deserialize, + ) + return self._stubs["list_feedback_labels"] + + @property + def get_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.GetFeedbackLabelRequest], resources.FeedbackLabel + ]: + r"""Return a callable for the get feedback label method over gRPC. + + Get feedback label. + + Returns: + Callable[[~.GetFeedbackLabelRequest], + ~.FeedbackLabel]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_feedback_label" not in self._stubs: + self._stubs["get_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetFeedbackLabel", + request_serializer=contact_center_insights.GetFeedbackLabelRequest.serialize, + response_deserializer=resources.FeedbackLabel.deserialize, + ) + return self._stubs["get_feedback_label"] + + @property + def update_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.UpdateFeedbackLabelRequest], resources.FeedbackLabel + ]: + r"""Return a callable for the update feedback label method over gRPC. + + Update feedback label. + + Returns: + Callable[[~.UpdateFeedbackLabelRequest], + ~.FeedbackLabel]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_feedback_label" not in self._stubs: + self._stubs["update_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateFeedbackLabel", + request_serializer=contact_center_insights.UpdateFeedbackLabelRequest.serialize, + response_deserializer=resources.FeedbackLabel.deserialize, + ) + return self._stubs["update_feedback_label"] + + @property + def delete_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.DeleteFeedbackLabelRequest], empty_pb2.Empty + ]: + r"""Return a callable for the delete feedback label method over gRPC. + + Delete feedback label. + + Returns: + Callable[[~.DeleteFeedbackLabelRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_feedback_label" not in self._stubs: + self._stubs["delete_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteFeedbackLabel", + request_serializer=contact_center_insights.DeleteFeedbackLabelRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_feedback_label"] + + @property + def list_all_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.ListAllFeedbackLabelsRequest], + contact_center_insights.ListAllFeedbackLabelsResponse, + ]: + r"""Return a callable for the list all feedback labels method over gRPC. + + List all feedback labels by project number. + + Returns: + Callable[[~.ListAllFeedbackLabelsRequest], + ~.ListAllFeedbackLabelsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_all_feedback_labels" not in self._stubs: + self._stubs["list_all_feedback_labels"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAllFeedbackLabels", + request_serializer=contact_center_insights.ListAllFeedbackLabelsRequest.serialize, + response_deserializer=contact_center_insights.ListAllFeedbackLabelsResponse.deserialize, + ) + return self._stubs["list_all_feedback_labels"] + + @property + def bulk_upload_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkUploadFeedbackLabelsRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the bulk upload feedback labels method over gRPC. + + Upload feedback labels in bulk. + + Returns: + Callable[[~.BulkUploadFeedbackLabelsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "bulk_upload_feedback_labels" not in self._stubs: + self._stubs["bulk_upload_feedback_labels"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkUploadFeedbackLabels", + request_serializer=contact_center_insights.BulkUploadFeedbackLabelsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["bulk_upload_feedback_labels"] + + @property + def bulk_download_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkDownloadFeedbackLabelsRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the bulk download feedback labels method over gRPC. + + Download feedback labels in bulk. + + Returns: + Callable[[~.BulkDownloadFeedbackLabelsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "bulk_download_feedback_labels" not in self._stubs: + self._stubs[ + "bulk_download_feedback_labels" + ] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkDownloadFeedbackLabels", + request_serializer=contact_center_insights.BulkDownloadFeedbackLabelsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["bulk_download_feedback_labels"] + def close(self): self.grpc_channel.close() diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py index f8d9502c1943..ab7b6c4cfb68 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py @@ -22,6 +22,8 @@ from google.api_core import retry_async as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -1310,20 +1312,799 @@ def update_settings( ) return self._stubs["update_settings"] + @property + def create_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.CreateAnalysisRuleRequest], + Awaitable[resources.AnalysisRule], + ]: + r"""Return a callable for the create analysis rule method over gRPC. + + Creates a analysis rule. + + Returns: + Callable[[~.CreateAnalysisRuleRequest], + Awaitable[~.AnalysisRule]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_analysis_rule" not in self._stubs: + self._stubs["create_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysisRule", + request_serializer=contact_center_insights.CreateAnalysisRuleRequest.serialize, + response_deserializer=resources.AnalysisRule.deserialize, + ) + return self._stubs["create_analysis_rule"] + + @property + def get_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.GetAnalysisRuleRequest], + Awaitable[resources.AnalysisRule], + ]: + r"""Return a callable for the get analysis rule method over gRPC. + + Get a analysis rule. + + Returns: + Callable[[~.GetAnalysisRuleRequest], + Awaitable[~.AnalysisRule]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_analysis_rule" not in self._stubs: + self._stubs["get_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysisRule", + request_serializer=contact_center_insights.GetAnalysisRuleRequest.serialize, + response_deserializer=resources.AnalysisRule.deserialize, + ) + return self._stubs["get_analysis_rule"] + + @property + def list_analysis_rules( + self, + ) -> Callable[ + [contact_center_insights.ListAnalysisRulesRequest], + Awaitable[contact_center_insights.ListAnalysisRulesResponse], + ]: + r"""Return a callable for the list analysis rules method over gRPC. + + Lists analysis rules. + + Returns: + Callable[[~.ListAnalysisRulesRequest], + Awaitable[~.ListAnalysisRulesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_analysis_rules" not in self._stubs: + self._stubs["list_analysis_rules"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalysisRules", + request_serializer=contact_center_insights.ListAnalysisRulesRequest.serialize, + response_deserializer=contact_center_insights.ListAnalysisRulesResponse.deserialize, + ) + return self._stubs["list_analysis_rules"] + + @property + def update_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.UpdateAnalysisRuleRequest], + Awaitable[resources.AnalysisRule], + ]: + r"""Return a callable for the update analysis rule method over gRPC. + + Updates a analysis rule. + + Returns: + Callable[[~.UpdateAnalysisRuleRequest], + Awaitable[~.AnalysisRule]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_analysis_rule" not in self._stubs: + self._stubs["update_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateAnalysisRule", + request_serializer=contact_center_insights.UpdateAnalysisRuleRequest.serialize, + response_deserializer=resources.AnalysisRule.deserialize, + ) + return self._stubs["update_analysis_rule"] + + @property + def delete_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.DeleteAnalysisRuleRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete analysis rule method over gRPC. + + Deletes a analysis rule. + + Returns: + Callable[[~.DeleteAnalysisRuleRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_analysis_rule" not in self._stubs: + self._stubs["delete_analysis_rule"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysisRule", + request_serializer=contact_center_insights.DeleteAnalysisRuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_analysis_rule"] + @property def get_encryption_spec( self, ) -> Callable[ - [contact_center_insights.GetEncryptionSpecRequest], - Awaitable[resources.EncryptionSpec], + [contact_center_insights.GetEncryptionSpecRequest], + Awaitable[resources.EncryptionSpec], + ]: + r"""Return a callable for the get encryption spec method over gRPC. + + Gets location-level encryption key specification. + + Returns: + Callable[[~.GetEncryptionSpecRequest], + Awaitable[~.EncryptionSpec]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_encryption_spec" not in self._stubs: + self._stubs["get_encryption_spec"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetEncryptionSpec", + request_serializer=contact_center_insights.GetEncryptionSpecRequest.serialize, + response_deserializer=resources.EncryptionSpec.deserialize, + ) + return self._stubs["get_encryption_spec"] + + @property + def initialize_encryption_spec( + self, + ) -> Callable[ + [contact_center_insights.InitializeEncryptionSpecRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the initialize encryption spec method over gRPC. + + Initializes a location-level encryption key + specification. An error will result if the location has + resources already created before the initialization. + After the encryption specification is initialized at a + location, it is immutable and all newly created + resources under the location will be encrypted with the + existing specification. + + Returns: + Callable[[~.InitializeEncryptionSpecRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "initialize_encryption_spec" not in self._stubs: + self._stubs["initialize_encryption_spec"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/InitializeEncryptionSpec", + request_serializer=contact_center_insights.InitializeEncryptionSpecRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["initialize_encryption_spec"] + + @property + def create_view( + self, + ) -> Callable[ + [contact_center_insights.CreateViewRequest], Awaitable[resources.View] + ]: + r"""Return a callable for the create view method over gRPC. + + Creates a view. + + Returns: + Callable[[~.CreateViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_view" not in self._stubs: + self._stubs["create_view"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView", + request_serializer=contact_center_insights.CreateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs["create_view"] + + @property + def get_view( + self, + ) -> Callable[[contact_center_insights.GetViewRequest], Awaitable[resources.View]]: + r"""Return a callable for the get view method over gRPC. + + Gets a view. + + Returns: + Callable[[~.GetViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_view" not in self._stubs: + self._stubs["get_view"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView", + request_serializer=contact_center_insights.GetViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs["get_view"] + + @property + def list_views( + self, + ) -> Callable[ + [contact_center_insights.ListViewsRequest], + Awaitable[contact_center_insights.ListViewsResponse], + ]: + r"""Return a callable for the list views method over gRPC. + + Lists views. + + Returns: + Callable[[~.ListViewsRequest], + Awaitable[~.ListViewsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_views" not in self._stubs: + self._stubs["list_views"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews", + request_serializer=contact_center_insights.ListViewsRequest.serialize, + response_deserializer=contact_center_insights.ListViewsResponse.deserialize, + ) + return self._stubs["list_views"] + + @property + def update_view( + self, + ) -> Callable[ + [contact_center_insights.UpdateViewRequest], Awaitable[resources.View] + ]: + r"""Return a callable for the update view method over gRPC. + + Updates a view. + + Returns: + Callable[[~.UpdateViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_view" not in self._stubs: + self._stubs["update_view"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView", + request_serializer=contact_center_insights.UpdateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs["update_view"] + + @property + def delete_view( + self, + ) -> Callable[ + [contact_center_insights.DeleteViewRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete view method over gRPC. + + Deletes a view. + + Returns: + Callable[[~.DeleteViewRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_view" not in self._stubs: + self._stubs["delete_view"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView", + request_serializer=contact_center_insights.DeleteViewRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_view"] + + @property + def query_metrics( + self, + ) -> Callable[ + [contact_center_insights.QueryMetricsRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the query metrics method over gRPC. + + Query metrics. + + Returns: + Callable[[~.QueryMetricsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "query_metrics" not in self._stubs: + self._stubs["query_metrics"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/QueryMetrics", + request_serializer=contact_center_insights.QueryMetricsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["query_metrics"] + + @property + def create_qa_question( + self, + ) -> Callable[ + [contact_center_insights.CreateQaQuestionRequest], + Awaitable[resources.QaQuestion], + ]: + r"""Return a callable for the create qa question method over gRPC. + + Create a QaQuestion. + + Returns: + Callable[[~.CreateQaQuestionRequest], + Awaitable[~.QaQuestion]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_qa_question" not in self._stubs: + self._stubs["create_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateQaQuestion", + request_serializer=contact_center_insights.CreateQaQuestionRequest.serialize, + response_deserializer=resources.QaQuestion.deserialize, + ) + return self._stubs["create_qa_question"] + + @property + def get_qa_question( + self, + ) -> Callable[ + [contact_center_insights.GetQaQuestionRequest], Awaitable[resources.QaQuestion] + ]: + r"""Return a callable for the get qa question method over gRPC. + + Gets a QaQuestion. + + Returns: + Callable[[~.GetQaQuestionRequest], + Awaitable[~.QaQuestion]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_qa_question" not in self._stubs: + self._stubs["get_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetQaQuestion", + request_serializer=contact_center_insights.GetQaQuestionRequest.serialize, + response_deserializer=resources.QaQuestion.deserialize, + ) + return self._stubs["get_qa_question"] + + @property + def update_qa_question( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaQuestionRequest], + Awaitable[resources.QaQuestion], + ]: + r"""Return a callable for the update qa question method over gRPC. + + Updates a QaQuestion. + + Returns: + Callable[[~.UpdateQaQuestionRequest], + Awaitable[~.QaQuestion]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_qa_question" not in self._stubs: + self._stubs["update_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateQaQuestion", + request_serializer=contact_center_insights.UpdateQaQuestionRequest.serialize, + response_deserializer=resources.QaQuestion.deserialize, + ) + return self._stubs["update_qa_question"] + + @property + def delete_qa_question( + self, + ) -> Callable[ + [contact_center_insights.DeleteQaQuestionRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete qa question method over gRPC. + + Deletes a QaQuestion. + + Returns: + Callable[[~.DeleteQaQuestionRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_qa_question" not in self._stubs: + self._stubs["delete_qa_question"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteQaQuestion", + request_serializer=contact_center_insights.DeleteQaQuestionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_qa_question"] + + @property + def list_qa_questions( + self, + ) -> Callable[ + [contact_center_insights.ListQaQuestionsRequest], + Awaitable[contact_center_insights.ListQaQuestionsResponse], + ]: + r"""Return a callable for the list qa questions method over gRPC. + + Lists QaQuestions. + + Returns: + Callable[[~.ListQaQuestionsRequest], + Awaitable[~.ListQaQuestionsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_qa_questions" not in self._stubs: + self._stubs["list_qa_questions"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListQaQuestions", + request_serializer=contact_center_insights.ListQaQuestionsRequest.serialize, + response_deserializer=contact_center_insights.ListQaQuestionsResponse.deserialize, + ) + return self._stubs["list_qa_questions"] + + @property + def create_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRequest], + Awaitable[resources.QaScorecard], + ]: + r"""Return a callable for the create qa scorecard method over gRPC. + + Create a QaScorecard. + + Returns: + Callable[[~.CreateQaScorecardRequest], + Awaitable[~.QaScorecard]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_qa_scorecard" not in self._stubs: + self._stubs["create_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateQaScorecard", + request_serializer=contact_center_insights.CreateQaScorecardRequest.serialize, + response_deserializer=resources.QaScorecard.deserialize, + ) + return self._stubs["create_qa_scorecard"] + + @property + def get_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRequest], + Awaitable[resources.QaScorecard], + ]: + r"""Return a callable for the get qa scorecard method over gRPC. + + Gets a QaScorecard. + + Returns: + Callable[[~.GetQaScorecardRequest], + Awaitable[~.QaScorecard]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_qa_scorecard" not in self._stubs: + self._stubs["get_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetQaScorecard", + request_serializer=contact_center_insights.GetQaScorecardRequest.serialize, + response_deserializer=resources.QaScorecard.deserialize, + ) + return self._stubs["get_qa_scorecard"] + + @property + def update_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaScorecardRequest], + Awaitable[resources.QaScorecard], + ]: + r"""Return a callable for the update qa scorecard method over gRPC. + + Updates a QaScorecard. + + Returns: + Callable[[~.UpdateQaScorecardRequest], + Awaitable[~.QaScorecard]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_qa_scorecard" not in self._stubs: + self._stubs["update_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateQaScorecard", + request_serializer=contact_center_insights.UpdateQaScorecardRequest.serialize, + response_deserializer=resources.QaScorecard.deserialize, + ) + return self._stubs["update_qa_scorecard"] + + @property + def delete_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.DeleteQaScorecardRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete qa scorecard method over gRPC. + + Deletes a QaScorecard. + + Returns: + Callable[[~.DeleteQaScorecardRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_qa_scorecard" not in self._stubs: + self._stubs["delete_qa_scorecard"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteQaScorecard", + request_serializer=contact_center_insights.DeleteQaScorecardRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_qa_scorecard"] + + @property + def list_qa_scorecards( + self, + ) -> Callable[ + [contact_center_insights.ListQaScorecardsRequest], + Awaitable[contact_center_insights.ListQaScorecardsResponse], + ]: + r"""Return a callable for the list qa scorecards method over gRPC. + + Lists QaScorecards. + + Returns: + Callable[[~.ListQaScorecardsRequest], + Awaitable[~.ListQaScorecardsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_qa_scorecards" not in self._stubs: + self._stubs["list_qa_scorecards"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListQaScorecards", + request_serializer=contact_center_insights.ListQaScorecardsRequest.serialize, + response_deserializer=contact_center_insights.ListQaScorecardsResponse.deserialize, + ) + return self._stubs["list_qa_scorecards"] + + @property + def create_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRevisionRequest], + Awaitable[resources.QaScorecardRevision], + ]: + r"""Return a callable for the create qa scorecard revision method over gRPC. + + Creates a QaScorecardRevision. + + Returns: + Callable[[~.CreateQaScorecardRevisionRequest], + Awaitable[~.QaScorecardRevision]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_qa_scorecard_revision" not in self._stubs: + self._stubs["create_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateQaScorecardRevision", + request_serializer=contact_center_insights.CreateQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, + ) + return self._stubs["create_qa_scorecard_revision"] + + @property + def get_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRevisionRequest], + Awaitable[resources.QaScorecardRevision], + ]: + r"""Return a callable for the get qa scorecard revision method over gRPC. + + Gets a QaScorecardRevision. + + Returns: + Callable[[~.GetQaScorecardRevisionRequest], + Awaitable[~.QaScorecardRevision]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_qa_scorecard_revision" not in self._stubs: + self._stubs["get_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetQaScorecardRevision", + request_serializer=contact_center_insights.GetQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, + ) + return self._stubs["get_qa_scorecard_revision"] + + @property + def tune_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.TuneQaScorecardRevisionRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the tune qa scorecard revision method over gRPC. + + Fine tune one or more QaModels. + + Returns: + Callable[[~.TuneQaScorecardRevisionRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "tune_qa_scorecard_revision" not in self._stubs: + self._stubs["tune_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/TuneQaScorecardRevision", + request_serializer=contact_center_insights.TuneQaScorecardRevisionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["tune_qa_scorecard_revision"] + + @property + def deploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.DeployQaScorecardRevisionRequest], + Awaitable[resources.QaScorecardRevision], + ]: + r"""Return a callable for the deploy qa scorecard revision method over gRPC. + + Deploy a QaScorecardRevision. + + Returns: + Callable[[~.DeployQaScorecardRevisionRequest], + Awaitable[~.QaScorecardRevision]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "deploy_qa_scorecard_revision" not in self._stubs: + self._stubs["deploy_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployQaScorecardRevision", + request_serializer=contact_center_insights.DeployQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, + ) + return self._stubs["deploy_qa_scorecard_revision"] + + @property + def undeploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.UndeployQaScorecardRevisionRequest], + Awaitable[resources.QaScorecardRevision], ]: - r"""Return a callable for the get encryption spec method over gRPC. + r"""Return a callable for the undeploy qa scorecard revision method over gRPC. - Gets location-level encryption key specification. + Undeploy a QaScorecardRevision. Returns: - Callable[[~.GetEncryptionSpecRequest], - Awaitable[~.EncryptionSpec]]: + Callable[[~.UndeployQaScorecardRevisionRequest], + Awaitable[~.QaScorecardRevision]]: A function that, when called, will call the underlying RPC on the server. """ @@ -1331,34 +2112,30 @@ def get_encryption_spec( # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if "get_encryption_spec" not in self._stubs: - self._stubs["get_encryption_spec"] = self.grpc_channel.unary_unary( - "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetEncryptionSpec", - request_serializer=contact_center_insights.GetEncryptionSpecRequest.serialize, - response_deserializer=resources.EncryptionSpec.deserialize, + if "undeploy_qa_scorecard_revision" not in self._stubs: + self._stubs[ + "undeploy_qa_scorecard_revision" + ] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployQaScorecardRevision", + request_serializer=contact_center_insights.UndeployQaScorecardRevisionRequest.serialize, + response_deserializer=resources.QaScorecardRevision.deserialize, ) - return self._stubs["get_encryption_spec"] + return self._stubs["undeploy_qa_scorecard_revision"] @property - def initialize_encryption_spec( + def delete_qa_scorecard_revision( self, ) -> Callable[ - [contact_center_insights.InitializeEncryptionSpecRequest], - Awaitable[operations_pb2.Operation], + [contact_center_insights.DeleteQaScorecardRevisionRequest], + Awaitable[empty_pb2.Empty], ]: - r"""Return a callable for the initialize encryption spec method over gRPC. + r"""Return a callable for the delete qa scorecard revision method over gRPC. - Initializes a location-level encryption key - specification. An error will be thrown if the location - has resources already created before the initialization. - Once the encryption specification is initialized at a - location, it is immutable and all newly created - resources under the location will be encrypted with the - existing specification. + Deletes a QaScorecardRevision. Returns: - Callable[[~.InitializeEncryptionSpecRequest], - Awaitable[~.Operation]]: + Callable[[~.DeleteQaScorecardRevisionRequest], + Awaitable[~.Empty]]: A function that, when called, will call the underlying RPC on the server. """ @@ -1366,27 +2143,28 @@ def initialize_encryption_spec( # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if "initialize_encryption_spec" not in self._stubs: - self._stubs["initialize_encryption_spec"] = self.grpc_channel.unary_unary( - "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/InitializeEncryptionSpec", - request_serializer=contact_center_insights.InitializeEncryptionSpecRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, + if "delete_qa_scorecard_revision" not in self._stubs: + self._stubs["delete_qa_scorecard_revision"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteQaScorecardRevision", + request_serializer=contact_center_insights.DeleteQaScorecardRevisionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, ) - return self._stubs["initialize_encryption_spec"] + return self._stubs["delete_qa_scorecard_revision"] @property - def create_view( + def list_qa_scorecard_revisions( self, ) -> Callable[ - [contact_center_insights.CreateViewRequest], Awaitable[resources.View] + [contact_center_insights.ListQaScorecardRevisionsRequest], + Awaitable[contact_center_insights.ListQaScorecardRevisionsResponse], ]: - r"""Return a callable for the create view method over gRPC. + r"""Return a callable for the list qa scorecard revisions method over gRPC. - Creates a view. + Lists all revisions under the parent QaScorecard. Returns: - Callable[[~.CreateViewRequest], - Awaitable[~.View]]: + Callable[[~.ListQaScorecardRevisionsRequest], + Awaitable[~.ListQaScorecardRevisionsResponse]]: A function that, when called, will call the underlying RPC on the server. """ @@ -1394,25 +2172,28 @@ def create_view( # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if "create_view" not in self._stubs: - self._stubs["create_view"] = self.grpc_channel.unary_unary( - "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView", - request_serializer=contact_center_insights.CreateViewRequest.serialize, - response_deserializer=resources.View.deserialize, + if "list_qa_scorecard_revisions" not in self._stubs: + self._stubs["list_qa_scorecard_revisions"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListQaScorecardRevisions", + request_serializer=contact_center_insights.ListQaScorecardRevisionsRequest.serialize, + response_deserializer=contact_center_insights.ListQaScorecardRevisionsResponse.deserialize, ) - return self._stubs["create_view"] + return self._stubs["list_qa_scorecard_revisions"] @property - def get_view( + def create_feedback_label( self, - ) -> Callable[[contact_center_insights.GetViewRequest], Awaitable[resources.View]]: - r"""Return a callable for the get view method over gRPC. + ) -> Callable[ + [contact_center_insights.CreateFeedbackLabelRequest], + Awaitable[resources.FeedbackLabel], + ]: + r"""Return a callable for the create feedback label method over gRPC. - Gets a view. + Create feedback label. Returns: - Callable[[~.GetViewRequest], - Awaitable[~.View]]: + Callable[[~.CreateFeedbackLabelRequest], + Awaitable[~.FeedbackLabel]]: A function that, when called, will call the underlying RPC on the server. """ @@ -1420,28 +2201,28 @@ def get_view( # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if "get_view" not in self._stubs: - self._stubs["get_view"] = self.grpc_channel.unary_unary( - "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView", - request_serializer=contact_center_insights.GetViewRequest.serialize, - response_deserializer=resources.View.deserialize, + if "create_feedback_label" not in self._stubs: + self._stubs["create_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateFeedbackLabel", + request_serializer=contact_center_insights.CreateFeedbackLabelRequest.serialize, + response_deserializer=resources.FeedbackLabel.deserialize, ) - return self._stubs["get_view"] + return self._stubs["create_feedback_label"] @property - def list_views( + def list_feedback_labels( self, ) -> Callable[ - [contact_center_insights.ListViewsRequest], - Awaitable[contact_center_insights.ListViewsResponse], + [contact_center_insights.ListFeedbackLabelsRequest], + Awaitable[contact_center_insights.ListFeedbackLabelsResponse], ]: - r"""Return a callable for the list views method over gRPC. + r"""Return a callable for the list feedback labels method over gRPC. - Lists views. + List feedback labels. Returns: - Callable[[~.ListViewsRequest], - Awaitable[~.ListViewsResponse]]: + Callable[[~.ListFeedbackLabelsRequest], + Awaitable[~.ListFeedbackLabelsResponse]]: A function that, when called, will call the underlying RPC on the server. """ @@ -1449,27 +2230,28 @@ def list_views( # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if "list_views" not in self._stubs: - self._stubs["list_views"] = self.grpc_channel.unary_unary( - "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews", - request_serializer=contact_center_insights.ListViewsRequest.serialize, - response_deserializer=contact_center_insights.ListViewsResponse.deserialize, + if "list_feedback_labels" not in self._stubs: + self._stubs["list_feedback_labels"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListFeedbackLabels", + request_serializer=contact_center_insights.ListFeedbackLabelsRequest.serialize, + response_deserializer=contact_center_insights.ListFeedbackLabelsResponse.deserialize, ) - return self._stubs["list_views"] + return self._stubs["list_feedback_labels"] @property - def update_view( + def get_feedback_label( self, ) -> Callable[ - [contact_center_insights.UpdateViewRequest], Awaitable[resources.View] + [contact_center_insights.GetFeedbackLabelRequest], + Awaitable[resources.FeedbackLabel], ]: - r"""Return a callable for the update view method over gRPC. + r"""Return a callable for the get feedback label method over gRPC. - Updates a view. + Get feedback label. Returns: - Callable[[~.UpdateViewRequest], - Awaitable[~.View]]: + Callable[[~.GetFeedbackLabelRequest], + Awaitable[~.FeedbackLabel]]: A function that, when called, will call the underlying RPC on the server. """ @@ -1477,26 +2259,55 @@ def update_view( # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if "update_view" not in self._stubs: - self._stubs["update_view"] = self.grpc_channel.unary_unary( - "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView", - request_serializer=contact_center_insights.UpdateViewRequest.serialize, - response_deserializer=resources.View.deserialize, + if "get_feedback_label" not in self._stubs: + self._stubs["get_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetFeedbackLabel", + request_serializer=contact_center_insights.GetFeedbackLabelRequest.serialize, + response_deserializer=resources.FeedbackLabel.deserialize, ) - return self._stubs["update_view"] + return self._stubs["get_feedback_label"] @property - def delete_view( + def update_feedback_label( self, ) -> Callable[ - [contact_center_insights.DeleteViewRequest], Awaitable[empty_pb2.Empty] + [contact_center_insights.UpdateFeedbackLabelRequest], + Awaitable[resources.FeedbackLabel], ]: - r"""Return a callable for the delete view method over gRPC. + r"""Return a callable for the update feedback label method over gRPC. - Deletes a view. + Update feedback label. Returns: - Callable[[~.DeleteViewRequest], + Callable[[~.UpdateFeedbackLabelRequest], + Awaitable[~.FeedbackLabel]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_feedback_label" not in self._stubs: + self._stubs["update_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateFeedbackLabel", + request_serializer=contact_center_insights.UpdateFeedbackLabelRequest.serialize, + response_deserializer=resources.FeedbackLabel.deserialize, + ) + return self._stubs["update_feedback_label"] + + @property + def delete_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.DeleteFeedbackLabelRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete feedback label method over gRPC. + + Delete feedback label. + + Returns: + Callable[[~.DeleteFeedbackLabelRequest], Awaitable[~.Empty]]: A function that, when called, will call the underlying RPC on the server. @@ -1505,13 +2316,102 @@ def delete_view( # the request. # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. - if "delete_view" not in self._stubs: - self._stubs["delete_view"] = self.grpc_channel.unary_unary( - "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView", - request_serializer=contact_center_insights.DeleteViewRequest.serialize, + if "delete_feedback_label" not in self._stubs: + self._stubs["delete_feedback_label"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteFeedbackLabel", + request_serializer=contact_center_insights.DeleteFeedbackLabelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, ) - return self._stubs["delete_view"] + return self._stubs["delete_feedback_label"] + + @property + def list_all_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.ListAllFeedbackLabelsRequest], + Awaitable[contact_center_insights.ListAllFeedbackLabelsResponse], + ]: + r"""Return a callable for the list all feedback labels method over gRPC. + + List all feedback labels by project number. + + Returns: + Callable[[~.ListAllFeedbackLabelsRequest], + Awaitable[~.ListAllFeedbackLabelsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_all_feedback_labels" not in self._stubs: + self._stubs["list_all_feedback_labels"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAllFeedbackLabels", + request_serializer=contact_center_insights.ListAllFeedbackLabelsRequest.serialize, + response_deserializer=contact_center_insights.ListAllFeedbackLabelsResponse.deserialize, + ) + return self._stubs["list_all_feedback_labels"] + + @property + def bulk_upload_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkUploadFeedbackLabelsRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the bulk upload feedback labels method over gRPC. + + Upload feedback labels in bulk. + + Returns: + Callable[[~.BulkUploadFeedbackLabelsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "bulk_upload_feedback_labels" not in self._stubs: + self._stubs["bulk_upload_feedback_labels"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkUploadFeedbackLabels", + request_serializer=contact_center_insights.BulkUploadFeedbackLabelsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["bulk_upload_feedback_labels"] + + @property + def bulk_download_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkDownloadFeedbackLabelsRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the bulk download feedback labels method over gRPC. + + Download feedback labels in bulk. + + Returns: + Callable[[~.BulkDownloadFeedbackLabelsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "bulk_download_feedback_labels" not in self._stubs: + self._stubs[ + "bulk_download_feedback_labels" + ] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkDownloadFeedbackLabels", + request_serializer=contact_center_insights.BulkDownloadFeedbackLabelsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["bulk_download_feedback_labels"] def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" @@ -1696,6 +2596,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_analysis_rule: self._wrap_method( + self.create_analysis_rule, + default_timeout=None, + client_info=client_info, + ), + self.get_analysis_rule: self._wrap_method( + self.get_analysis_rule, + default_timeout=None, + client_info=client_info, + ), + self.list_analysis_rules: self._wrap_method( + self.list_analysis_rules, + default_timeout=None, + client_info=client_info, + ), + self.update_analysis_rule: self._wrap_method( + self.update_analysis_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_analysis_rule: self._wrap_method( + self.delete_analysis_rule, + default_timeout=None, + client_info=client_info, + ), self.get_encryption_spec: self._wrap_method( self.get_encryption_spec, default_timeout=None, @@ -1731,6 +2656,136 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.query_metrics: self._wrap_method( + self.query_metrics, + default_timeout=None, + client_info=client_info, + ), + self.create_qa_question: self._wrap_method( + self.create_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.get_qa_question: self._wrap_method( + self.get_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.update_qa_question: self._wrap_method( + self.update_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.delete_qa_question: self._wrap_method( + self.delete_qa_question, + default_timeout=None, + client_info=client_info, + ), + self.list_qa_questions: self._wrap_method( + self.list_qa_questions, + default_timeout=None, + client_info=client_info, + ), + self.create_qa_scorecard: self._wrap_method( + self.create_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.get_qa_scorecard: self._wrap_method( + self.get_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.update_qa_scorecard: self._wrap_method( + self.update_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.delete_qa_scorecard: self._wrap_method( + self.delete_qa_scorecard, + default_timeout=None, + client_info=client_info, + ), + self.list_qa_scorecards: self._wrap_method( + self.list_qa_scorecards, + default_timeout=None, + client_info=client_info, + ), + self.create_qa_scorecard_revision: self._wrap_method( + self.create_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.get_qa_scorecard_revision: self._wrap_method( + self.get_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.tune_qa_scorecard_revision: self._wrap_method( + self.tune_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.deploy_qa_scorecard_revision: self._wrap_method( + self.deploy_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.undeploy_qa_scorecard_revision: self._wrap_method( + self.undeploy_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.delete_qa_scorecard_revision: self._wrap_method( + self.delete_qa_scorecard_revision, + default_timeout=None, + client_info=client_info, + ), + self.list_qa_scorecard_revisions: self._wrap_method( + self.list_qa_scorecard_revisions, + default_timeout=None, + client_info=client_info, + ), + self.create_feedback_label: self._wrap_method( + self.create_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.list_feedback_labels: self._wrap_method( + self.list_feedback_labels, + default_timeout=None, + client_info=client_info, + ), + self.get_feedback_label: self._wrap_method( + self.get_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.update_feedback_label: self._wrap_method( + self.update_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.delete_feedback_label: self._wrap_method( + self.delete_feedback_label, + default_timeout=None, + client_info=client_info, + ), + self.list_all_feedback_labels: self._wrap_method( + self.list_all_feedback_labels, + default_timeout=None, + client_info=client_info, + ), + self.bulk_upload_feedback_labels: self._wrap_method( + self.bulk_upload_feedback_labels, + default_timeout=None, + client_info=client_info, + ), + self.bulk_download_feedback_labels: self._wrap_method( + self.bulk_download_feedback_labels, + default_timeout=None, + client_info=client_info, + ), self.cancel_operation: self._wrap_method( self.cancel_operation, default_timeout=None, diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py index 0f4c30cb1252..0a682f23aa89 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py @@ -24,6 +24,8 @@ from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import json_format @@ -81,6 +83,22 @@ def post_bulk_delete_conversations(self, response): logging.log(f"Received response: {response}") return response + def pre_bulk_download_feedback_labels(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_bulk_download_feedback_labels(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_bulk_upload_feedback_labels(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_bulk_upload_feedback_labels(self, response): + logging.log(f"Received response: {response}") + return response + def pre_calculate_issue_model_stats(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -105,6 +123,14 @@ def post_create_analysis(self, response): logging.log(f"Received response: {response}") return response + def pre_create_analysis_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_analysis_rule(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_conversation(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -113,6 +139,14 @@ def post_create_conversation(self, response): logging.log(f"Received response: {response}") return response + def pre_create_feedback_label(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_feedback_label(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_issue_model(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -129,6 +163,30 @@ def post_create_phrase_matcher(self, response): logging.log(f"Received response: {response}") return response + def pre_create_qa_question(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_qa_question(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_qa_scorecard(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_qa_scorecard(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_qa_scorecard_revision(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_qa_scorecard_revision(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_view(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -141,10 +199,18 @@ def pre_delete_analysis(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def pre_delete_analysis_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_delete_conversation(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def pre_delete_feedback_label(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_delete_issue(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -161,6 +227,18 @@ def pre_delete_phrase_matcher(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def pre_delete_qa_question(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_delete_qa_scorecard(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_delete_qa_scorecard_revision(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_delete_view(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -173,6 +251,14 @@ def post_deploy_issue_model(self, response): logging.log(f"Received response: {response}") return response + def pre_deploy_qa_scorecard_revision(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_deploy_qa_scorecard_revision(self, response): + logging.log(f"Received response: {response}") + return response + def pre_export_insights_data(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -197,6 +283,14 @@ def post_get_analysis(self, response): logging.log(f"Received response: {response}") return response + def pre_get_analysis_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_analysis_rule(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_conversation(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -213,6 +307,14 @@ def post_get_encryption_spec(self, response): logging.log(f"Received response: {response}") return response + def pre_get_feedback_label(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_feedback_label(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_issue(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -237,6 +339,30 @@ def post_get_phrase_matcher(self, response): logging.log(f"Received response: {response}") return response + def pre_get_qa_question(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_qa_question(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_qa_scorecard(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_qa_scorecard(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_qa_scorecard_revision(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_qa_scorecard_revision(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_settings(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -277,6 +403,14 @@ def post_initialize_encryption_spec(self, response): logging.log(f"Received response: {response}") return response + def pre_list_all_feedback_labels(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_all_feedback_labels(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_analyses(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -285,6 +419,14 @@ def post_list_analyses(self, response): logging.log(f"Received response: {response}") return response + def pre_list_analysis_rules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_analysis_rules(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_conversations(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -293,6 +435,14 @@ def post_list_conversations(self, response): logging.log(f"Received response: {response}") return response + def pre_list_feedback_labels(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_feedback_labels(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_issue_models(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -317,6 +467,30 @@ def post_list_phrase_matchers(self, response): logging.log(f"Received response: {response}") return response + def pre_list_qa_questions(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_qa_questions(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_qa_scorecard_revisions(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_qa_scorecard_revisions(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_qa_scorecards(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_qa_scorecards(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_views(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -325,6 +499,22 @@ def post_list_views(self, response): logging.log(f"Received response: {response}") return response + def pre_query_metrics(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_query_metrics(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_tune_qa_scorecard_revision(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_tune_qa_scorecard_revision(self, response): + logging.log(f"Received response: {response}") + return response + def pre_undeploy_issue_model(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -333,6 +523,22 @@ def post_undeploy_issue_model(self, response): logging.log(f"Received response: {response}") return response + def pre_undeploy_qa_scorecard_revision(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_undeploy_qa_scorecard_revision(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_analysis_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_analysis_rule(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_conversation(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -341,6 +547,14 @@ def post_update_conversation(self, response): logging.log(f"Received response: {response}") return response + def pre_update_feedback_label(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_feedback_label(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_issue(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -365,6 +579,22 @@ def post_update_phrase_matcher(self, response): logging.log(f"Received response: {response}") return response + def pre_update_qa_question(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_qa_question(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_qa_scorecard(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_qa_scorecard(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_settings(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -447,6 +677,58 @@ def post_bulk_delete_conversations( """ return response + def pre_bulk_download_feedback_labels( + self, + request: contact_center_insights.BulkDownloadFeedbackLabelsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.BulkDownloadFeedbackLabelsRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for bulk_download_feedback_labels + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_bulk_download_feedback_labels( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for bulk_download_feedback_labels + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_bulk_upload_feedback_labels( + self, + request: contact_center_insights.BulkUploadFeedbackLabelsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.BulkUploadFeedbackLabelsRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for bulk_upload_feedback_labels + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_bulk_upload_feedback_labels( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for bulk_upload_feedback_labels + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_calculate_issue_model_stats( self, request: contact_center_insights.CalculateIssueModelStatsRequest, @@ -523,6 +805,31 @@ def post_create_analysis( """ return response + def pre_create_analysis_rule( + self, + request: contact_center_insights.CreateAnalysisRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.CreateAnalysisRuleRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for create_analysis_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_analysis_rule( + self, response: resources.AnalysisRule + ) -> resources.AnalysisRule: + """Post-rpc interceptor for create_analysis_rule + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_create_conversation( self, request: contact_center_insights.CreateConversationRequest, @@ -548,6 +855,31 @@ def post_create_conversation( """ return response + def pre_create_feedback_label( + self, + request: contact_center_insights.CreateFeedbackLabelRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.CreateFeedbackLabelRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for create_feedback_label + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_feedback_label( + self, response: resources.FeedbackLabel + ) -> resources.FeedbackLabel: + """Post-rpc interceptor for create_feedback_label + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_create_issue_model( self, request: contact_center_insights.CreateIssueModelRequest, @@ -598,20 +930,24 @@ def post_create_phrase_matcher( """ return response - def pre_create_view( + def pre_create_qa_question( self, - request: contact_center_insights.CreateViewRequest, + request: contact_center_insights.CreateQaQuestionRequest, metadata: Sequence[Tuple[str, str]], - ) -> Tuple[contact_center_insights.CreateViewRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_view + ) -> Tuple[ + contact_center_insights.CreateQaQuestionRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for create_qa_question Override in a subclass to manipulate the request or metadata before they are sent to the ContactCenterInsights server. """ return request, metadata - def post_create_view(self, response: resources.View) -> resources.View: - """Post-rpc interceptor for create_view + def post_create_qa_question( + self, response: resources.QaQuestion + ) -> resources.QaQuestion: + """Post-rpc interceptor for create_qa_question Override in a subclass to manipulate the response after it is returned by the ContactCenterInsights server but before @@ -619,12 +955,84 @@ def post_create_view(self, response: resources.View) -> resources.View: """ return response - def pre_delete_analysis( + def pre_create_qa_scorecard( self, - request: contact_center_insights.DeleteAnalysisRequest, + request: contact_center_insights.CreateQaScorecardRequest, metadata: Sequence[Tuple[str, str]], ) -> Tuple[ - contact_center_insights.DeleteAnalysisRequest, Sequence[Tuple[str, str]] + contact_center_insights.CreateQaScorecardRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for create_qa_scorecard + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_qa_scorecard( + self, response: resources.QaScorecard + ) -> resources.QaScorecard: + """Post-rpc interceptor for create_qa_scorecard + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_create_qa_scorecard_revision( + self, + request: contact_center_insights.CreateQaScorecardRevisionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.CreateQaScorecardRevisionRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for create_qa_scorecard_revision + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_qa_scorecard_revision( + self, response: resources.QaScorecardRevision + ) -> resources.QaScorecardRevision: + """Post-rpc interceptor for create_qa_scorecard_revision + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_create_view( + self, + request: contact_center_insights.CreateViewRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[contact_center_insights.CreateViewRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_view + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_view(self, response: resources.View) -> resources.View: + """Post-rpc interceptor for create_view + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_delete_analysis( + self, + request: contact_center_insights.DeleteAnalysisRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.DeleteAnalysisRequest, Sequence[Tuple[str, str]] ]: """Pre-rpc interceptor for delete_analysis @@ -633,6 +1041,20 @@ def pre_delete_analysis( """ return request, metadata + def pre_delete_analysis_rule( + self, + request: contact_center_insights.DeleteAnalysisRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.DeleteAnalysisRuleRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for delete_analysis_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + def pre_delete_conversation( self, request: contact_center_insights.DeleteConversationRequest, @@ -647,6 +1069,20 @@ def pre_delete_conversation( """ return request, metadata + def pre_delete_feedback_label( + self, + request: contact_center_insights.DeleteFeedbackLabelRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.DeleteFeedbackLabelRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for delete_feedback_label + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + def pre_delete_issue( self, request: contact_center_insights.DeleteIssueRequest, @@ -698,6 +1134,49 @@ def pre_delete_phrase_matcher( """ return request, metadata + def pre_delete_qa_question( + self, + request: contact_center_insights.DeleteQaQuestionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.DeleteQaQuestionRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for delete_qa_question + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def pre_delete_qa_scorecard( + self, + request: contact_center_insights.DeleteQaScorecardRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.DeleteQaScorecardRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for delete_qa_scorecard + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def pre_delete_qa_scorecard_revision( + self, + request: contact_center_insights.DeleteQaScorecardRevisionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.DeleteQaScorecardRevisionRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for delete_qa_scorecard_revision + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + def pre_delete_view( self, request: contact_center_insights.DeleteViewRequest, @@ -735,6 +1214,32 @@ def post_deploy_issue_model( """ return response + def pre_deploy_qa_scorecard_revision( + self, + request: contact_center_insights.DeployQaScorecardRevisionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.DeployQaScorecardRevisionRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for deploy_qa_scorecard_revision + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_deploy_qa_scorecard_revision( + self, response: resources.QaScorecardRevision + ) -> resources.QaScorecardRevision: + """Post-rpc interceptor for deploy_qa_scorecard_revision + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_export_insights_data( self, request: contact_center_insights.ExportInsightsDataRequest, @@ -806,6 +1311,31 @@ def post_get_analysis(self, response: resources.Analysis) -> resources.Analysis: """ return response + def pre_get_analysis_rule( + self, + request: contact_center_insights.GetAnalysisRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.GetAnalysisRuleRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for get_analysis_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_analysis_rule( + self, response: resources.AnalysisRule + ) -> resources.AnalysisRule: + """Post-rpc interceptor for get_analysis_rule + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_conversation( self, request: contact_center_insights.GetConversationRequest, @@ -856,6 +1386,31 @@ def post_get_encryption_spec( """ return response + def pre_get_feedback_label( + self, + request: contact_center_insights.GetFeedbackLabelRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.GetFeedbackLabelRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for get_feedback_label + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_feedback_label( + self, response: resources.FeedbackLabel + ) -> resources.FeedbackLabel: + """Post-rpc interceptor for get_feedback_label + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_issue( self, request: contact_center_insights.GetIssueRequest, @@ -925,6 +1480,79 @@ def post_get_phrase_matcher( """ return response + def pre_get_qa_question( + self, + request: contact_center_insights.GetQaQuestionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[contact_center_insights.GetQaQuestionRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_qa_question + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_qa_question( + self, response: resources.QaQuestion + ) -> resources.QaQuestion: + """Post-rpc interceptor for get_qa_question + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_get_qa_scorecard( + self, + request: contact_center_insights.GetQaScorecardRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.GetQaScorecardRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for get_qa_scorecard + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_qa_scorecard( + self, response: resources.QaScorecard + ) -> resources.QaScorecard: + """Post-rpc interceptor for get_qa_scorecard + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_get_qa_scorecard_revision( + self, + request: contact_center_insights.GetQaScorecardRevisionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.GetQaScorecardRevisionRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for get_qa_scorecard_revision + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_qa_scorecard_revision( + self, response: resources.QaScorecardRevision + ) -> resources.QaScorecardRevision: + """Post-rpc interceptor for get_qa_scorecard_revision + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_settings( self, request: contact_center_insights.GetSettingsRequest, @@ -1043,6 +1671,31 @@ def post_initialize_encryption_spec( """ return response + def pre_list_all_feedback_labels( + self, + request: contact_center_insights.ListAllFeedbackLabelsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.ListAllFeedbackLabelsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for list_all_feedback_labels + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_all_feedback_labels( + self, response: contact_center_insights.ListAllFeedbackLabelsResponse + ) -> contact_center_insights.ListAllFeedbackLabelsResponse: + """Post-rpc interceptor for list_all_feedback_labels + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_analyses( self, request: contact_center_insights.ListAnalysesRequest, @@ -1066,6 +1719,31 @@ def post_list_analyses( """ return response + def pre_list_analysis_rules( + self, + request: contact_center_insights.ListAnalysisRulesRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.ListAnalysisRulesRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for list_analysis_rules + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_analysis_rules( + self, response: contact_center_insights.ListAnalysisRulesResponse + ) -> contact_center_insights.ListAnalysisRulesResponse: + """Post-rpc interceptor for list_analysis_rules + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_conversations( self, request: contact_center_insights.ListConversationsRequest, @@ -1091,24 +1769,24 @@ def post_list_conversations( """ return response - def pre_list_issue_models( + def pre_list_feedback_labels( self, - request: contact_center_insights.ListIssueModelsRequest, + request: contact_center_insights.ListFeedbackLabelsRequest, metadata: Sequence[Tuple[str, str]], ) -> Tuple[ - contact_center_insights.ListIssueModelsRequest, Sequence[Tuple[str, str]] + contact_center_insights.ListFeedbackLabelsRequest, Sequence[Tuple[str, str]] ]: - """Pre-rpc interceptor for list_issue_models + """Pre-rpc interceptor for list_feedback_labels Override in a subclass to manipulate the request or metadata before they are sent to the ContactCenterInsights server. """ return request, metadata - def post_list_issue_models( - self, response: contact_center_insights.ListIssueModelsResponse - ) -> contact_center_insights.ListIssueModelsResponse: - """Post-rpc interceptor for list_issue_models + def post_list_feedback_labels( + self, response: contact_center_insights.ListFeedbackLabelsResponse + ) -> contact_center_insights.ListFeedbackLabelsResponse: + """Post-rpc interceptor for list_feedback_labels Override in a subclass to manipulate the response after it is returned by the ContactCenterInsights server but before @@ -1116,9 +1794,34 @@ def post_list_issue_models( """ return response - def pre_list_issues( + def pre_list_issue_models( self, - request: contact_center_insights.ListIssuesRequest, + request: contact_center_insights.ListIssueModelsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.ListIssueModelsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for list_issue_models + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_issue_models( + self, response: contact_center_insights.ListIssueModelsResponse + ) -> contact_center_insights.ListIssueModelsResponse: + """Post-rpc interceptor for list_issue_models + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_list_issues( + self, + request: contact_center_insights.ListIssuesRequest, metadata: Sequence[Tuple[str, str]], ) -> Tuple[contact_center_insights.ListIssuesRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for list_issues @@ -1164,6 +1867,82 @@ def post_list_phrase_matchers( """ return response + def pre_list_qa_questions( + self, + request: contact_center_insights.ListQaQuestionsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.ListQaQuestionsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for list_qa_questions + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_qa_questions( + self, response: contact_center_insights.ListQaQuestionsResponse + ) -> contact_center_insights.ListQaQuestionsResponse: + """Post-rpc interceptor for list_qa_questions + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_list_qa_scorecard_revisions( + self, + request: contact_center_insights.ListQaScorecardRevisionsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.ListQaScorecardRevisionsRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for list_qa_scorecard_revisions + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_qa_scorecard_revisions( + self, response: contact_center_insights.ListQaScorecardRevisionsResponse + ) -> contact_center_insights.ListQaScorecardRevisionsResponse: + """Post-rpc interceptor for list_qa_scorecard_revisions + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_list_qa_scorecards( + self, + request: contact_center_insights.ListQaScorecardsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.ListQaScorecardsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for list_qa_scorecards + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_qa_scorecards( + self, response: contact_center_insights.ListQaScorecardsResponse + ) -> contact_center_insights.ListQaScorecardsResponse: + """Post-rpc interceptor for list_qa_scorecards + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_views( self, request: contact_center_insights.ListViewsRequest, @@ -1187,6 +1966,55 @@ def post_list_views( """ return response + def pre_query_metrics( + self, + request: contact_center_insights.QueryMetricsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[contact_center_insights.QueryMetricsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for query_metrics + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_query_metrics( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for query_metrics + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_tune_qa_scorecard_revision( + self, + request: contact_center_insights.TuneQaScorecardRevisionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.TuneQaScorecardRevisionRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for tune_qa_scorecard_revision + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_tune_qa_scorecard_revision( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for tune_qa_scorecard_revision + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_undeploy_issue_model( self, request: contact_center_insights.UndeployIssueModelRequest, @@ -1212,6 +2040,57 @@ def post_undeploy_issue_model( """ return response + def pre_undeploy_qa_scorecard_revision( + self, + request: contact_center_insights.UndeployQaScorecardRevisionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.UndeployQaScorecardRevisionRequest, + Sequence[Tuple[str, str]], + ]: + """Pre-rpc interceptor for undeploy_qa_scorecard_revision + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_undeploy_qa_scorecard_revision( + self, response: resources.QaScorecardRevision + ) -> resources.QaScorecardRevision: + """Post-rpc interceptor for undeploy_qa_scorecard_revision + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_update_analysis_rule( + self, + request: contact_center_insights.UpdateAnalysisRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.UpdateAnalysisRuleRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for update_analysis_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_analysis_rule( + self, response: resources.AnalysisRule + ) -> resources.AnalysisRule: + """Post-rpc interceptor for update_analysis_rule + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_conversation( self, request: contact_center_insights.UpdateConversationRequest, @@ -1237,6 +2116,31 @@ def post_update_conversation( """ return response + def pre_update_feedback_label( + self, + request: contact_center_insights.UpdateFeedbackLabelRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.UpdateFeedbackLabelRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for update_feedback_label + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_feedback_label( + self, response: resources.FeedbackLabel + ) -> resources.FeedbackLabel: + """Post-rpc interceptor for update_feedback_label + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_issue( self, request: contact_center_insights.UpdateIssueRequest, @@ -1308,6 +2212,56 @@ def post_update_phrase_matcher( """ return response + def pre_update_qa_question( + self, + request: contact_center_insights.UpdateQaQuestionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.UpdateQaQuestionRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for update_qa_question + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_qa_question( + self, response: resources.QaQuestion + ) -> resources.QaQuestion: + """Post-rpc interceptor for update_qa_question + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_update_qa_scorecard( + self, + request: contact_center_insights.UpdateQaScorecardRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + contact_center_insights.UpdateQaScorecardRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for update_qa_scorecard + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_qa_scorecard( + self, response: resources.QaScorecard + ) -> resources.QaScorecard: + """Post-rpc interceptor for update_qa_scorecard + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_settings( self, request: contact_center_insights.UpdateSettingsRequest, @@ -1778,12 +2732,12 @@ def __call__( resp = self._interceptor.post_bulk_delete_conversations(resp) return resp - class _CalculateIssueModelStats( - _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats, + class _BulkDownloadFeedbackLabels( + _BaseContactCenterInsightsRestTransport._BaseBulkDownloadFeedbackLabels, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.CalculateIssueModelStats") + return hash("ContactCenterInsightsRestTransport.BulkDownloadFeedbackLabels") @staticmethod def _get_response( @@ -1804,24 +2758,25 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.CalculateIssueModelStatsRequest, + request: contact_center_insights.BulkDownloadFeedbackLabelsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.CalculateIssueModelStatsResponse: - r"""Call the calculate issue model - stats method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the bulk download feedback + labels method over HTTP. Args: - request (~.contact_center_insights.CalculateIssueModelStatsRequest): - The request object. Request to get statistics of an issue - model. + request (~.contact_center_insights.BulkDownloadFeedbackLabelsRequest): + The request object. Request for the + BulkDownloadFeedbackLabel endpoint. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1829,35 +2784,41 @@ def __call__( sent along with the request as metadata. Returns: - ~.contact_center_insights.CalculateIssueModelStatsResponse: - Response of querying an issue model's - statistics. + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseBulkDownloadFeedbackLabels._get_http_options() ) - request, metadata = self._interceptor.pre_calculate_issue_model_stats( + request, metadata = self._interceptor.pre_bulk_download_feedback_labels( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseBulkDownloadFeedbackLabels._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseBulkDownloadFeedbackLabels._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseBulkDownloadFeedbackLabels._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._CalculateIssueModelStats._get_response( + response = ContactCenterInsightsRestTransport._BulkDownloadFeedbackLabels._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1866,19 +2827,17 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.CalculateIssueModelStatsResponse() - pb_resp = contact_center_insights.CalculateIssueModelStatsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_calculate_issue_model_stats(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_download_feedback_labels(resp) return resp - class _CalculateStats( - _BaseContactCenterInsightsRestTransport._BaseCalculateStats, + class _BulkUploadFeedbackLabels( + _BaseContactCenterInsightsRestTransport._BaseBulkUploadFeedbackLabels, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.CalculateStats") + return hash("ContactCenterInsightsRestTransport.BulkUploadFeedbackLabels") @staticmethod def _get_response( @@ -1899,57 +2858,67 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.CalculateStatsRequest, + request: contact_center_insights.BulkUploadFeedbackLabelsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.CalculateStatsResponse: - r"""Call the calculate stats method over HTTP. - - Args: - request (~.contact_center_insights.CalculateStatsRequest): - The request object. The request for calculating - conversation statistics. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + ) -> operations_pb2.Operation: + r"""Call the bulk upload feedback + labels method over HTTP. - Returns: - ~.contact_center_insights.CalculateStatsResponse: - The response for calculating - conversation statistics. + Args: + request (~.contact_center_insights.BulkUploadFeedbackLabelsRequest): + The request object. The request for bulk uploading + feedback labels. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseBulkUploadFeedbackLabels._get_http_options() ) - request, metadata = self._interceptor.pre_calculate_stats(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_transcoded_request( + request, metadata = self._interceptor.pre_bulk_upload_feedback_labels( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseBulkUploadFeedbackLabels._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseBulkUploadFeedbackLabels._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseBulkUploadFeedbackLabels._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._CalculateStats._get_response( + response = ContactCenterInsightsRestTransport._BulkUploadFeedbackLabels._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1958,19 +2927,17 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.CalculateStatsResponse() - pb_resp = contact_center_insights.CalculateStatsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_calculate_stats(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_upload_feedback_labels(resp) return resp - class _CreateAnalysis( - _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis, + class _CalculateIssueModelStats( + _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.CreateAnalysis") + return hash("ContactCenterInsightsRestTransport.CalculateIssueModelStats") @staticmethod def _get_response( @@ -1991,63 +2958,60 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: contact_center_insights.CreateAnalysisRequest, + request: contact_center_insights.CalculateIssueModelStatsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the create analysis method over HTTP. + ) -> contact_center_insights.CalculateIssueModelStatsResponse: + r"""Call the calculate issue model + stats method over HTTP. - Args: - request (~.contact_center_insights.CreateAnalysisRequest): - The request object. The request to create an analysis. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + Args: + request (~.contact_center_insights.CalculateIssueModelStatsRequest): + The request object. Request to get statistics of an issue + model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + Returns: + ~.contact_center_insights.CalculateIssueModelStatsResponse: + Response of querying an issue model's + statistics. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_http_options() ) - request, metadata = self._interceptor.pre_create_analysis(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_transcoded_request( - http_options, request + request, metadata = self._interceptor.pre_calculate_issue_model_stats( + request, metadata ) - - body = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_request_body_json( - transcoded_request + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_transcoded_request( + http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._CreateAnalysis._get_response( + response = ContactCenterInsightsRestTransport._CalculateIssueModelStats._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2056,17 +3020,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_analysis(resp) + resp = contact_center_insights.CalculateIssueModelStatsResponse() + pb_resp = contact_center_insights.CalculateIssueModelStatsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_calculate_issue_model_stats(resp) return resp - class _CreateConversation( - _BaseContactCenterInsightsRestTransport._BaseCreateConversation, + class _CalculateStats( + _BaseContactCenterInsightsRestTransport._BaseCalculateStats, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.CreateConversation") + return hash("ContactCenterInsightsRestTransport.CalculateStats") @staticmethod def _get_response( @@ -2087,23 +3053,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: contact_center_insights.CreateConversationRequest, + request: contact_center_insights.CalculateStatsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Call the create conversation method over HTTP. + ) -> contact_center_insights.CalculateStatsResponse: + r"""Call the calculate stats method over HTTP. Args: - request (~.contact_center_insights.CreateConversationRequest): - The request object. Request to create a conversation. + request (~.contact_center_insights.CalculateStatsRequest): + The request object. The request for calculating + conversation statistics. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2111,40 +3077,33 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.Conversation: - The conversation resource. + ~.contact_center_insights.CalculateStatsResponse: + The response for calculating + conversation statistics. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_http_options() - ) - request, metadata = self._interceptor.pre_create_conversation( - request, metadata + _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_http_options() ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_transcoded_request( + request, metadata = self._interceptor.pre_calculate_stats(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_query_params_json( transcoded_request ) # Send the request - response = ( - ContactCenterInsightsRestTransport._CreateConversation._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) + response = ContactCenterInsightsRestTransport._CalculateStats._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2153,19 +3112,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.Conversation() - pb_resp = resources.Conversation.pb(resp) + resp = contact_center_insights.CalculateStatsResponse() + pb_resp = contact_center_insights.CalculateStatsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_conversation(resp) + resp = self._interceptor.post_calculate_stats(resp) return resp - class _CreateIssueModel( - _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel, + class _CreateAnalysis( + _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.CreateIssueModel") + return hash("ContactCenterInsightsRestTransport.CreateAnalysis") @staticmethod def _get_response( @@ -2192,17 +3151,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.CreateIssueModelRequest, + request: contact_center_insights.CreateAnalysisRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: - r"""Call the create issue model method over HTTP. + r"""Call the create analysis method over HTTP. Args: - request (~.contact_center_insights.CreateIssueModelRequest): - The request object. The request to create an issue model. + request (~.contact_center_insights.CreateAnalysisRequest): + The request object. The request to create an analysis. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2218,35 +3177,31 @@ def __call__( """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_http_options() - ) - request, metadata = self._interceptor.pre_create_issue_model( - request, metadata + _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_http_options() ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_transcoded_request( + request, metadata = self._interceptor.pre_create_analysis(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_query_params_json( transcoded_request ) # Send the request - response = ( - ContactCenterInsightsRestTransport._CreateIssueModel._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) + response = ContactCenterInsightsRestTransport._CreateAnalysis._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2257,15 +3212,15 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_issue_model(resp) + resp = self._interceptor.post_create_analysis(resp) return resp - class _CreatePhraseMatcher( - _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher, + class _CreateAnalysisRule( + _BaseContactCenterInsightsRestTransport._BaseCreateAnalysisRule, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.CreatePhraseMatcher") + return hash("ContactCenterInsightsRestTransport.CreateAnalysisRule") @staticmethod def _get_response( @@ -2292,17 +3247,18 @@ def _get_response( def __call__( self, - request: contact_center_insights.CreatePhraseMatcherRequest, + request: contact_center_insights.CreateAnalysisRuleRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Call the create phrase matcher method over HTTP. + ) -> resources.AnalysisRule: + r"""Call the create analysis rule method over HTTP. Args: - request (~.contact_center_insights.CreatePhraseMatcherRequest): - The request object. Request to create a phrase matcher. + request (~.contact_center_insights.CreateAnalysisRuleRequest): + The request object. The request to create a analysis rule. analysis_rule_id + will be generated by the server. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2310,32 +3266,42 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.PhraseMatcher: - The phrase matcher resource. + ~.resources.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreateAnalysisRule._get_http_options() ) - request, metadata = self._interceptor.pre_create_phrase_matcher( + request, metadata = self._interceptor.pre_create_analysis_rule( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysisRule._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysisRule._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateAnalysisRule._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._CreatePhraseMatcher._get_response( + ContactCenterInsightsRestTransport._CreateAnalysisRule._get_response( self._host, metadata, query_params, @@ -2352,19 +3318,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.PhraseMatcher() - pb_resp = resources.PhraseMatcher.pb(resp) + resp = resources.AnalysisRule() + pb_resp = resources.AnalysisRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_phrase_matcher(resp) + resp = self._interceptor.post_create_analysis_rule(resp) return resp - class _CreateView( - _BaseContactCenterInsightsRestTransport._BaseCreateView, + class _CreateConversation( + _BaseContactCenterInsightsRestTransport._BaseCreateConversation, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.CreateView") + return hash("ContactCenterInsightsRestTransport.CreateConversation") @staticmethod def _get_response( @@ -2391,17 +3357,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.CreateViewRequest, + request: contact_center_insights.CreateConversationRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Call the create view method over HTTP. + ) -> resources.Conversation: + r"""Call the create conversation method over HTTP. Args: - request (~.contact_center_insights.CreateViewRequest): - The request object. The request to create a view. + request (~.contact_center_insights.CreateConversationRequest): + The request object. Request to create a conversation. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2409,36 +3375,40 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.View: - The View resource. + ~.resources.Conversation: + The conversation resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseCreateView._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_http_options() ) - request, metadata = self._interceptor.pre_create_view(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateView._get_transcoded_request( + request, metadata = self._interceptor.pre_create_conversation( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseCreateView._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseCreateView._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._CreateView._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, + response = ( + ContactCenterInsightsRestTransport._CreateConversation._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2447,19 +3417,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.View() - pb_resp = resources.View.pb(resp) + resp = resources.Conversation() + pb_resp = resources.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_view(resp) + resp = self._interceptor.post_create_conversation(resp) return resp - class _DeleteAnalysis( - _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis, + class _CreateFeedbackLabel( + _BaseContactCenterInsightsRestTransport._BaseCreateFeedbackLabel, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.DeleteAnalysis") + return hash("ContactCenterInsightsRestTransport.CreateFeedbackLabel") @staticmethod def _get_response( @@ -2480,50 +3450,67 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.DeleteAnalysisRequest, + request: contact_center_insights.CreateFeedbackLabelRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ): - r"""Call the delete analysis method over HTTP. + ) -> resources.FeedbackLabel: + r"""Call the create feedback label method over HTTP. Args: - request (~.contact_center_insights.DeleteAnalysisRequest): - The request object. The request to delete an analysis. + request (~.contact_center_insights.CreateFeedbackLabelRequest): + The request object. The request for creating a feedback + label. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + ~.resources.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreateFeedbackLabel._get_http_options() ) - request, metadata = self._interceptor.pre_delete_analysis(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_transcoded_request( + request, metadata = self._interceptor.pre_create_feedback_label( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateFeedbackLabel._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseCreateFeedbackLabel._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateFeedbackLabel._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._DeleteAnalysis._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + ContactCenterInsightsRestTransport._CreateFeedbackLabel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2531,12 +3518,20 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _DeleteConversation( - _BaseContactCenterInsightsRestTransport._BaseDeleteConversation, + # Return the response + resp = resources.FeedbackLabel() + pb_resp = resources.FeedbackLabel.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_feedback_label(resp) + return resp + + class _CreateIssueModel( + _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.DeleteConversation") + return hash("ContactCenterInsightsRestTransport.CreateIssueModel") @staticmethod def _get_response( @@ -2557,53 +3552,66 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.DeleteConversationRequest, + request: contact_center_insights.CreateIssueModelRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ): - r"""Call the delete conversation method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the create issue model method over HTTP. Args: - request (~.contact_center_insights.DeleteConversationRequest): - The request object. The request to delete a conversation. + request (~.contact_center_insights.CreateIssueModelRequest): + The request object. The request to create an issue model. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_http_options() ) - request, metadata = self._interceptor.pre_delete_conversation( + request, metadata = self._interceptor.pre_create_issue_model( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._DeleteConversation._get_response( + ContactCenterInsightsRestTransport._CreateIssueModel._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) ) @@ -2612,12 +3620,18 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _DeleteIssue( - _BaseContactCenterInsightsRestTransport._BaseDeleteIssue, + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_issue_model(resp) + return resp + + class _CreatePhraseMatcher( + _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.DeleteIssue") + return hash("ContactCenterInsightsRestTransport.CreatePhraseMatcher") @staticmethod def _get_response( @@ -2638,50 +3652,64 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.DeleteIssueRequest, + request: contact_center_insights.CreatePhraseMatcherRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ): - r"""Call the delete issue method over HTTP. + ) -> resources.PhraseMatcher: + r"""Call the create phrase matcher method over HTTP. Args: - request (~.contact_center_insights.DeleteIssueRequest): - The request object. The request to delete an issue. + request (~.contact_center_insights.CreatePhraseMatcherRequest): + The request object. Request to create a phrase matcher. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + ~.resources.PhraseMatcher: + The phrase matcher resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_http_options() ) - request, metadata = self._interceptor.pre_delete_issue(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_transcoded_request( + request, metadata = self._interceptor.pre_create_phrase_matcher( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._DeleteIssue._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + ContactCenterInsightsRestTransport._CreatePhraseMatcher._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2689,12 +3717,20 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _DeleteIssueModel( - _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel, + # Return the response + resp = resources.PhraseMatcher() + pb_resp = resources.PhraseMatcher.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_phrase_matcher(resp) + return resp + + class _CreateQaQuestion( + _BaseContactCenterInsightsRestTransport._BaseCreateQaQuestion, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.DeleteIssueModel") + return hash("ContactCenterInsightsRestTransport.CreateQaQuestion") @staticmethod def _get_response( @@ -2715,22 +3751,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.DeleteIssueModelRequest, + request: contact_center_insights.CreateQaQuestionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the delete issue model method over HTTP. + ) -> resources.QaQuestion: + r"""Call the create qa question method over HTTP. Args: - request (~.contact_center_insights.DeleteIssueModelRequest): - The request object. The request to delete an issue model. + request (~.contact_center_insights.CreateQaQuestionRequest): + The request object. The request for creating a + QaQuestion. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2738,37 +3776,41 @@ def __call__( sent along with the request as metadata. Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + ~.resources.QaQuestion: + A single question to be scored by the + Insights QA feature. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreateQaQuestion._get_http_options() ) - request, metadata = self._interceptor.pre_delete_issue_model( + request, metadata = self._interceptor.pre_create_qa_question( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateQaQuestion._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseCreateQaQuestion._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateQaQuestion._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._DeleteIssueModel._get_response( + ContactCenterInsightsRestTransport._CreateQaQuestion._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) ) @@ -2778,17 +3820,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_issue_model(resp) + resp = resources.QaQuestion() + pb_resp = resources.QaQuestion.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_qa_question(resp) return resp - class _DeletePhraseMatcher( - _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher, + class _CreateQaScorecard( + _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecard, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.DeletePhraseMatcher") + return hash("ContactCenterInsightsRestTransport.CreateQaScorecard") @staticmethod def _get_response( @@ -2809,54 +3853,67 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.DeletePhraseMatcherRequest, + request: contact_center_insights.CreateQaScorecardRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ): - r"""Call the delete phrase matcher method over HTTP. + ) -> resources.QaScorecard: + r"""Call the create qa scorecard method over HTTP. Args: - request (~.contact_center_insights.DeletePhraseMatcherRequest): - The request object. The request to delete a phrase - matcher. + request (~.contact_center_insights.CreateQaScorecardRequest): + The request object. The request for creating a + QaScorecard. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + ~.resources.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecard._get_http_options() ) - request, metadata = self._interceptor.pre_delete_phrase_matcher( + request, metadata = self._interceptor.pre_create_qa_scorecard( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecard._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecard._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecard._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._DeletePhraseMatcher._get_response( + ContactCenterInsightsRestTransport._CreateQaScorecard._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) ) @@ -2865,12 +3922,20 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _DeleteView( - _BaseContactCenterInsightsRestTransport._BaseDeleteView, + # Return the response + resp = resources.QaScorecard() + pb_resp = resources.QaScorecard.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_qa_scorecard(resp) + return resp + + class _CreateQaScorecardRevision( + _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecardRevision, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.DeleteView") + return hash("ContactCenterInsightsRestTransport.CreateQaScorecardRevision") @staticmethod def _get_response( @@ -2891,50 +3956,74 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.DeleteViewRequest, + request: contact_center_insights.CreateQaScorecardRevisionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ): - r"""Call the delete view method over HTTP. + ) -> resources.QaScorecardRevision: + r"""Call the create qa scorecard + revision method over HTTP. + + Args: + request (~.contact_center_insights.CreateQaScorecardRevisionRequest): + The request object. The request for creating a + QaScorecardRevision. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. - Args: - request (~.contact_center_insights.DeleteViewRequest): - The request object. The request to delete a view. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecardRevision._get_http_options() ) - request, metadata = self._interceptor.pre_delete_view(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_transcoded_request( + request, metadata = self._interceptor.pre_create_qa_scorecard_revision( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecardRevision._get_transcoded_request( http_options, request ) - # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_query_params_json( + body = _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecardRevision._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecardRevision._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._DeleteView._get_response( + response = ContactCenterInsightsRestTransport._CreateQaScorecardRevision._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2942,12 +4031,20 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _DeployIssueModel( - _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel, + # Return the response + resp = resources.QaScorecardRevision() + pb_resp = resources.QaScorecardRevision.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_qa_scorecard_revision(resp) + return resp + + class _CreateView( + _BaseContactCenterInsightsRestTransport._BaseCreateView, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.DeployIssueModel") + return hash("ContactCenterInsightsRestTransport.CreateView") @staticmethod def _get_response( @@ -2974,17 +4071,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.DeployIssueModelRequest, + request: contact_center_insights.CreateViewRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the deploy issue model method over HTTP. + ) -> resources.View: + r"""Call the create view method over HTTP. Args: - request (~.contact_center_insights.DeployIssueModelRequest): - The request object. The request to deploy an issue model. + request (~.contact_center_insights.CreateViewRequest): + The request object. The request to create a view. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2992,43 +4089,36 @@ def __call__( sent along with the request as metadata. Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - + ~.resources.View: + The View resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_http_options() - ) - request, metadata = self._interceptor.pre_deploy_issue_model( - request, metadata + _BaseContactCenterInsightsRestTransport._BaseCreateView._get_http_options() ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_transcoded_request( + request, metadata = self._interceptor.pre_create_view(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseCreateView._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseCreateView._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseCreateView._get_query_params_json( transcoded_request ) # Send the request - response = ( - ContactCenterInsightsRestTransport._DeployIssueModel._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) + response = ContactCenterInsightsRestTransport._CreateView._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3037,17 +4127,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_deploy_issue_model(resp) + resp = resources.View() + pb_resp = resources.View.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_view(resp) return resp - class _ExportInsightsData( - _BaseContactCenterInsightsRestTransport._BaseExportInsightsData, + class _DeleteAnalysis( + _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ExportInsightsData") + return hash("ContactCenterInsightsRestTransport.DeleteAnalysis") @staticmethod def _get_response( @@ -3068,67 +4160,50 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: contact_center_insights.ExportInsightsDataRequest, + request: contact_center_insights.DeleteAnalysisRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the export insights data method over HTTP. + ): + r"""Call the delete analysis method over HTTP. Args: - request (~.contact_center_insights.ExportInsightsDataRequest): - The request object. The request to export insights. + request (~.contact_center_insights.DeleteAnalysisRequest): + The request object. The request to delete an analysis. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_http_options() - ) - request, metadata = self._interceptor.pre_export_insights_data( - request, metadata + _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_http_options() ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_transcoded_request( + request, metadata = self._interceptor.pre_delete_analysis(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_query_params_json( transcoded_request ) # Send the request - response = ( - ContactCenterInsightsRestTransport._ExportInsightsData._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) + response = ContactCenterInsightsRestTransport._DeleteAnalysis._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3136,18 +4211,12 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_export_insights_data(resp) - return resp - - class _ExportIssueModel( - _BaseContactCenterInsightsRestTransport._BaseExportIssueModel, + class _DeleteAnalysisRule( + _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysisRule, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ExportIssueModel") + return hash("ContactCenterInsightsRestTransport.DeleteAnalysisRule") @staticmethod def _get_response( @@ -3168,66 +4237,54 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: contact_center_insights.ExportIssueModelRequest, + request: contact_center_insights.DeleteAnalysisRuleRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the export issue model method over HTTP. + ): + r"""Call the delete analysis rule method over HTTP. Args: - request (~.contact_center_insights.ExportIssueModelRequest): - The request object. Request to export an issue model. + request (~.contact_center_insights.DeleteAnalysisRuleRequest): + The request object. The request to delete a analysis + rule. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysisRule._get_http_options() ) - request, metadata = self._interceptor.pre_export_issue_model( + request, metadata = self._interceptor.pre_delete_analysis_rule( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysisRule._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysisRule._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._ExportIssueModel._get_response( + ContactCenterInsightsRestTransport._DeleteAnalysisRule._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) ) @@ -3236,18 +4293,12 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_export_issue_model(resp) - return resp - - class _GetAnalysis( - _BaseContactCenterInsightsRestTransport._BaseGetAnalysis, + class _DeleteConversation( + _BaseContactCenterInsightsRestTransport._BaseDeleteConversation, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetAnalysis") + return hash("ContactCenterInsightsRestTransport.DeleteConversation") @staticmethod def _get_response( @@ -3273,49 +4324,49 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetAnalysisRequest, + request: contact_center_insights.DeleteConversationRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Analysis: - r"""Call the get analysis method over HTTP. + ): + r"""Call the delete conversation method over HTTP. Args: - request (~.contact_center_insights.GetAnalysisRequest): - The request object. The request to get an analysis. + request (~.contact_center_insights.DeleteConversationRequest): + The request object. The request to delete a conversation. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. - - Returns: - ~.resources.Analysis: - The analysis resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_http_options() ) - request, metadata = self._interceptor.pre_get_analysis(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_transcoded_request( + request, metadata = self._interceptor.pre_delete_conversation( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._GetAnalysis._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + ContactCenterInsightsRestTransport._DeleteConversation._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3323,20 +4374,12 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - # Return the response - resp = resources.Analysis() - pb_resp = resources.Analysis.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_analysis(resp) - return resp - - class _GetConversation( - _BaseContactCenterInsightsRestTransport._BaseGetConversation, + class _DeleteFeedbackLabel( + _BaseContactCenterInsightsRestTransport._BaseDeleteFeedbackLabel, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetConversation") + return hash("ContactCenterInsightsRestTransport.DeleteFeedbackLabel") @staticmethod def _get_response( @@ -3362,46 +4405,43 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetConversationRequest, + request: contact_center_insights.DeleteFeedbackLabelRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Call the get conversation method over HTTP. + ): + r"""Call the delete feedback label method over HTTP. Args: - request (~.contact_center_insights.GetConversationRequest): - The request object. The request to get a conversation. + request (~.contact_center_insights.DeleteFeedbackLabelRequest): + The request object. The request for deleting a feedback + label. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. - - Returns: - ~.resources.Conversation: - The conversation resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseDeleteFeedbackLabel._get_http_options() ) - request, metadata = self._interceptor.pre_get_conversation( + request, metadata = self._interceptor.pre_delete_feedback_label( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteFeedbackLabel._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteFeedbackLabel._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._GetConversation._get_response( + ContactCenterInsightsRestTransport._DeleteFeedbackLabel._get_response( self._host, metadata, query_params, @@ -3416,20 +4456,12 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - # Return the response - resp = resources.Conversation() - pb_resp = resources.Conversation.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_conversation(resp) - return resp - - class _GetEncryptionSpec( - _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec, + class _DeleteIssue( + _BaseContactCenterInsightsRestTransport._BaseDeleteIssue, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetEncryptionSpec") + return hash("ContactCenterInsightsRestTransport.DeleteIssue") @staticmethod def _get_response( @@ -3455,18 +4487,2710 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetEncryptionSpecRequest, + request: contact_center_insights.DeleteIssueRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.EncryptionSpec: - r"""Call the get encryption spec method over HTTP. + ): + r"""Call the delete issue method over HTTP. + + Args: + request (~.contact_center_insights.DeleteIssueRequest): + The request object. The request to delete an issue. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_issue(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._DeleteIssue._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteIssueModel( + _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeleteIssueModel") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.DeleteIssueModelRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete issue model method over HTTP. + + Args: + request (~.contact_center_insights.DeleteIssueModelRequest): + The request object. The request to delete an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_issue_model( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._DeleteIssueModel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_issue_model(resp) + return resp + + class _DeletePhraseMatcher( + _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeletePhraseMatcher") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.DeletePhraseMatcherRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete phrase matcher method over HTTP. + + Args: + request (~.contact_center_insights.DeletePhraseMatcherRequest): + The request object. The request to delete a phrase + matcher. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_phrase_matcher( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._DeletePhraseMatcher._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteQaQuestion( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaQuestion, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeleteQaQuestion") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.DeleteQaQuestionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete qa question method over HTTP. + + Args: + request (~.contact_center_insights.DeleteQaQuestionRequest): + The request object. The request for deleting a + QaQuestion. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaQuestion._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_qa_question( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteQaQuestion._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteQaQuestion._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._DeleteQaQuestion._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteQaScorecard( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecard, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeleteQaScorecard") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.DeleteQaScorecardRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete qa scorecard method over HTTP. + + Args: + request (~.contact_center_insights.DeleteQaScorecardRequest): + The request object. The request for deleting a + QaScorecard. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecard._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_qa_scorecard( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecard._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecard._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._DeleteQaScorecard._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteQaScorecardRevision( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecardRevision, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeleteQaScorecardRevision") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.DeleteQaScorecardRevisionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete qa scorecard + revision method over HTTP. + + Args: + request (~.contact_center_insights.DeleteQaScorecardRevisionRequest): + The request object. The request to delete a + QaScorecardRevision. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecardRevision._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_qa_scorecard_revision( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecardRevision._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecardRevision._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._DeleteQaScorecardRevision._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteView( + _BaseContactCenterInsightsRestTransport._BaseDeleteView, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeleteView") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.DeleteViewRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete view method over HTTP. + + Args: + request (~.contact_center_insights.DeleteViewRequest): + The request object. The request to delete a view. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_view(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._DeleteView._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeployIssueModel( + _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeployIssueModel") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: contact_center_insights.DeployIssueModelRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the deploy issue model method over HTTP. + + Args: + request (~.contact_center_insights.DeployIssueModelRequest): + The request object. The request to deploy an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_http_options() + ) + request, metadata = self._interceptor.pre_deploy_issue_model( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_transcoded_request( + http_options, request + ) + + body = _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._DeployIssueModel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_issue_model(resp) + return resp + + class _DeployQaScorecardRevision( + _BaseContactCenterInsightsRestTransport._BaseDeployQaScorecardRevision, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.DeployQaScorecardRevision") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: contact_center_insights.DeployQaScorecardRevisionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Call the deploy qa scorecard + revision method over HTTP. + + Args: + request (~.contact_center_insights.DeployQaScorecardRevisionRequest): + The request object. The request to deploy a + QaScorecardRevision + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseDeployQaScorecardRevision._get_http_options() + ) + request, metadata = self._interceptor.pre_deploy_qa_scorecard_revision( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseDeployQaScorecardRevision._get_transcoded_request( + http_options, request + ) + + body = _BaseContactCenterInsightsRestTransport._BaseDeployQaScorecardRevision._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseDeployQaScorecardRevision._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._DeployQaScorecardRevision._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.QaScorecardRevision() + pb_resp = resources.QaScorecardRevision.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_qa_scorecard_revision(resp) + return resp + + class _ExportInsightsData( + _BaseContactCenterInsightsRestTransport._BaseExportInsightsData, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ExportInsightsData") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: contact_center_insights.ExportInsightsDataRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the export insights data method over HTTP. + + Args: + request (~.contact_center_insights.ExportInsightsDataRequest): + The request object. The request to export insights. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_http_options() + ) + request, metadata = self._interceptor.pre_export_insights_data( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_transcoded_request( + http_options, request + ) + + body = _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._ExportInsightsData._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_insights_data(resp) + return resp + + class _ExportIssueModel( + _BaseContactCenterInsightsRestTransport._BaseExportIssueModel, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ExportIssueModel") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: contact_center_insights.ExportIssueModelRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the export issue model method over HTTP. + + Args: + request (~.contact_center_insights.ExportIssueModelRequest): + The request object. Request to export an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_http_options() + ) + request, metadata = self._interceptor.pre_export_issue_model( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_transcoded_request( + http_options, request + ) + + body = _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._ExportIssueModel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_issue_model(resp) + return resp + + class _GetAnalysis( + _BaseContactCenterInsightsRestTransport._BaseGetAnalysis, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetAnalysis") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetAnalysisRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Analysis: + r"""Call the get analysis method over HTTP. + + Args: + request (~.contact_center_insights.GetAnalysisRequest): + The request object. The request to get an analysis. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Analysis: + The analysis resource. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_http_options() + ) + request, metadata = self._interceptor.pre_get_analysis(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetAnalysis._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Analysis() + pb_resp = resources.Analysis.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_analysis(resp) + return resp + + class _GetAnalysisRule( + _BaseContactCenterInsightsRestTransport._BaseGetAnalysisRule, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetAnalysisRule") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetAnalysisRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AnalysisRule: + r"""Call the get analysis rule method over HTTP. + + Args: + request (~.contact_center_insights.GetAnalysisRuleRequest): + The request object. The request for getting a analysis + rule. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetAnalysisRule._get_http_options() + ) + request, metadata = self._interceptor.pre_get_analysis_rule( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetAnalysisRule._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetAnalysisRule._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._GetAnalysisRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.AnalysisRule() + pb_resp = resources.AnalysisRule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_analysis_rule(resp) + return resp + + class _GetConversation( + _BaseContactCenterInsightsRestTransport._BaseGetConversation, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetConversation") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetConversationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Call the get conversation method over HTTP. + + Args: + request (~.contact_center_insights.GetConversationRequest): + The request object. The request to get a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Conversation: + The conversation resource. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_http_options() + ) + request, metadata = self._interceptor.pre_get_conversation( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._GetConversation._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Conversation() + pb_resp = resources.Conversation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation(resp) + return resp + + class _GetEncryptionSpec( + _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetEncryptionSpec") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetEncryptionSpecRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.EncryptionSpec: + r"""Call the get encryption spec method over HTTP. + + Args: + request (~.contact_center_insights.GetEncryptionSpecRequest): + The request object. The request to get location-level + encryption specification. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.EncryptionSpec: + A customer-managed encryption key specification that can + be applied to all created resources (e.g. + ``Conversation``). + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_http_options() + ) + request, metadata = self._interceptor.pre_get_encryption_spec( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._GetEncryptionSpec._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.EncryptionSpec() + pb_resp = resources.EncryptionSpec.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_encryption_spec(resp) + return resp + + class _GetFeedbackLabel( + _BaseContactCenterInsightsRestTransport._BaseGetFeedbackLabel, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetFeedbackLabel") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetFeedbackLabelRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FeedbackLabel: + r"""Call the get feedback label method over HTTP. + + Args: + request (~.contact_center_insights.GetFeedbackLabelRequest): + The request object. The request for getting a feedback + label. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetFeedbackLabel._get_http_options() + ) + request, metadata = self._interceptor.pre_get_feedback_label( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetFeedbackLabel._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetFeedbackLabel._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._GetFeedbackLabel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.FeedbackLabel() + pb_resp = resources.FeedbackLabel.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_feedback_label(resp) + return resp + + class _GetIssue( + _BaseContactCenterInsightsRestTransport._BaseGetIssue, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetIssue") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetIssueRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Call the get issue method over HTTP. + + Args: + request (~.contact_center_insights.GetIssueRequest): + The request object. The request to get an issue. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Issue: + The issue resource. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_http_options() + ) + request, metadata = self._interceptor.pre_get_issue(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetIssue._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Issue() + pb_resp = resources.Issue.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_issue(resp) + return resp + + class _GetIssueModel( + _BaseContactCenterInsightsRestTransport._BaseGetIssueModel, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetIssueModel") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetIssueModelRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Call the get issue model method over HTTP. + + Args: + request (~.contact_center_insights.GetIssueModelRequest): + The request object. The request to get an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.IssueModel: + The issue model resource. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_http_options() + ) + request, metadata = self._interceptor.pre_get_issue_model(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetIssueModel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.IssueModel() + pb_resp = resources.IssueModel.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_issue_model(resp) + return resp + + class _GetPhraseMatcher( + _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetPhraseMatcher") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetPhraseMatcherRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Call the get phrase matcher method over HTTP. + + Args: + request (~.contact_center_insights.GetPhraseMatcherRequest): + The request object. The request to get a a phrase + matcher. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.PhraseMatcher: + The phrase matcher resource. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_http_options() + ) + request, metadata = self._interceptor.pre_get_phrase_matcher( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._GetPhraseMatcher._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.PhraseMatcher() + pb_resp = resources.PhraseMatcher.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_phrase_matcher(resp) + return resp + + class _GetQaQuestion( + _BaseContactCenterInsightsRestTransport._BaseGetQaQuestion, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetQaQuestion") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetQaQuestionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaQuestion: + r"""Call the get qa question method over HTTP. + + Args: + request (~.contact_center_insights.GetQaQuestionRequest): + The request object. The request for a QaQuestion. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.QaQuestion: + A single question to be scored by the + Insights QA feature. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetQaQuestion._get_http_options() + ) + request, metadata = self._interceptor.pre_get_qa_question(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetQaQuestion._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetQaQuestion._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetQaQuestion._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.QaQuestion() + pb_resp = resources.QaQuestion.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_qa_question(resp) + return resp + + class _GetQaScorecard( + _BaseContactCenterInsightsRestTransport._BaseGetQaScorecard, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetQaScorecard") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetQaScorecardRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecard: + r"""Call the get qa scorecard method over HTTP. + + Args: + request (~.contact_center_insights.GetQaScorecardRequest): + The request object. The request for a QaScorecard. By + default, returns the latest revision. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetQaScorecard._get_http_options() + ) + request, metadata = self._interceptor.pre_get_qa_scorecard( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetQaScorecard._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetQaScorecard._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetQaScorecard._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.QaScorecard() + pb_resp = resources.QaScorecard.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_qa_scorecard(resp) + return resp + + class _GetQaScorecardRevision( + _BaseContactCenterInsightsRestTransport._BaseGetQaScorecardRevision, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetQaScorecardRevision") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetQaScorecardRevisionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.QaScorecardRevision: + r"""Call the get qa scorecard revision method over HTTP. + + Args: + request (~.contact_center_insights.GetQaScorecardRevisionRequest): + The request object. The request for a + QaScorecardRevision. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetQaScorecardRevision._get_http_options() + ) + request, metadata = self._interceptor.pre_get_qa_scorecard_revision( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetQaScorecardRevision._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetQaScorecardRevision._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetQaScorecardRevision._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.QaScorecardRevision() + pb_resp = resources.QaScorecardRevision.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_qa_scorecard_revision(resp) + return resp + + class _GetSettings( + _BaseContactCenterInsightsRestTransport._BaseGetSettings, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetSettings") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetSettingsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Call the get settings method over HTTP. + + Args: + request (~.contact_center_insights.GetSettingsRequest): + The request object. The request to get project-level + settings. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Settings: + The CCAI Insights project wide settings. Use these + settings to configure the behavior of Insights. View + these settings with + ```getsettings`` `__ + and change the settings with + ```updateSettings`` `__. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_http_options() + ) + request, metadata = self._interceptor.pre_get_settings(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetSettings._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Settings() + pb_resp = resources.Settings.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_settings(resp) + return resp + + class _GetView( + _BaseContactCenterInsightsRestTransport._BaseGetView, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.GetView") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.GetViewRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Call the get view method over HTTP. + + Args: + request (~.contact_center_insights.GetViewRequest): + The request object. The request to get a view. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.View: + The View resource. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseGetView._get_http_options() + ) + request, metadata = self._interceptor.pre_get_view(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetView._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseGetView._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._GetView._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.View() + pb_resp = resources.View.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_view(resp) + return resp + + class _ImportIssueModel( + _BaseContactCenterInsightsRestTransport._BaseImportIssueModel, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ImportIssueModel") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: contact_center_insights.ImportIssueModelRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the import issue model method over HTTP. + + Args: + request (~.contact_center_insights.ImportIssueModelRequest): + The request object. Request to import an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_http_options() + ) + request, metadata = self._interceptor.pre_import_issue_model( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_transcoded_request( + http_options, request + ) + + body = _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._ImportIssueModel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_issue_model(resp) + return resp + + class _IngestConversations( + _BaseContactCenterInsightsRestTransport._BaseIngestConversations, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.IngestConversations") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: contact_center_insights.IngestConversationsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the ingest conversations method over HTTP. + + Args: + request (~.contact_center_insights.IngestConversationsRequest): + The request object. The request to ingest conversations. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_http_options() + ) + request, metadata = self._interceptor.pre_ingest_conversations( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_transcoded_request( + http_options, request + ) + + body = _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._IngestConversations._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_ingest_conversations(resp) + return resp + + class _InitializeEncryptionSpec( + _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.InitializeEncryptionSpec") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: contact_center_insights.InitializeEncryptionSpecRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the initialize encryption + spec method over HTTP. + + Args: + request (~.contact_center_insights.InitializeEncryptionSpecRequest): + The request object. The request to initialize a + location-level encryption specification. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_http_options() + ) + request, metadata = self._interceptor.pre_initialize_encryption_spec( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_transcoded_request( + http_options, request + ) + + body = _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._InitializeEncryptionSpec._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_initialize_encryption_spec(resp) + return resp + + class _ListAllFeedbackLabels( + _BaseContactCenterInsightsRestTransport._BaseListAllFeedbackLabels, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ListAllFeedbackLabels") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.ListAllFeedbackLabelsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListAllFeedbackLabelsResponse: + r"""Call the list all feedback labels method over HTTP. + + Args: + request (~.contact_center_insights.ListAllFeedbackLabelsRequest): + The request object. The request for listing all feedback + labels. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListAllFeedbackLabelsResponse: + The response for listing all feedback + labels. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseListAllFeedbackLabels._get_http_options() + ) + request, metadata = self._interceptor.pre_list_all_feedback_labels( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListAllFeedbackLabels._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseListAllFeedbackLabels._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._ListAllFeedbackLabels._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListAllFeedbackLabelsResponse() + pb_resp = contact_center_insights.ListAllFeedbackLabelsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_all_feedback_labels(resp) + return resp + + class _ListAnalyses( + _BaseContactCenterInsightsRestTransport._BaseListAnalyses, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ListAnalyses") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.ListAnalysesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListAnalysesResponse: + r"""Call the list analyses method over HTTP. + + Args: + request (~.contact_center_insights.ListAnalysesRequest): + The request object. The request to list analyses. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListAnalysesResponse: + The response to list analyses. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_http_options() + ) + request, metadata = self._interceptor.pre_list_analyses(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ContactCenterInsightsRestTransport._ListAnalyses._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListAnalysesResponse() + pb_resp = contact_center_insights.ListAnalysesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analyses(resp) + return resp + + class _ListAnalysisRules( + _BaseContactCenterInsightsRestTransport._BaseListAnalysisRules, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ListAnalysisRules") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.ListAnalysisRulesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListAnalysisRulesResponse: + r"""Call the list analysis rules method over HTTP. Args: - request (~.contact_center_insights.GetEncryptionSpecRequest): - The request object. The request to get location-level - encryption specification. + request (~.contact_center_insights.ListAnalysisRulesRequest): + The request object. The request to list analysis rules. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3474,31 +7198,123 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.EncryptionSpec: - A customer-managed encryption key - specification that can be applied to all - created resources (e.g. Conversation). + ~.contact_center_insights.ListAnalysisRulesResponse: + The response of listing views. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseListAnalysisRules._get_http_options() + ) + request, metadata = self._interceptor.pre_list_analysis_rules( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListAnalysisRules._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseListAnalysisRules._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._ListAnalysisRules._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListAnalysisRulesResponse() + pb_resp = contact_center_insights.ListAnalysisRulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analysis_rules(resp) + return resp + + class _ListConversations( + _BaseContactCenterInsightsRestTransport._BaseListConversations, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ListConversations") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.ListConversationsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListConversationsResponse: + r"""Call the list conversations method over HTTP. + + Args: + request (~.contact_center_insights.ListConversationsRequest): + The request object. Request to list conversations. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListConversationsResponse: + The response of listing + conversations. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseListConversations._get_http_options() ) - request, metadata = self._interceptor.pre_get_encryption_spec( + request, metadata = self._interceptor.pre_list_conversations( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListConversations._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListConversations._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._GetEncryptionSpec._get_response( + ContactCenterInsightsRestTransport._ListConversations._get_response( self._host, metadata, query_params, @@ -3514,19 +7330,115 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.EncryptionSpec() - pb_resp = resources.EncryptionSpec.pb(resp) + resp = contact_center_insights.ListConversationsResponse() + pb_resp = contact_center_insights.ListConversationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_encryption_spec(resp) + resp = self._interceptor.post_list_conversations(resp) return resp - class _GetIssue( - _BaseContactCenterInsightsRestTransport._BaseGetIssue, + class _ListFeedbackLabels( + _BaseContactCenterInsightsRestTransport._BaseListFeedbackLabels, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetIssue") + return hash("ContactCenterInsightsRestTransport.ListFeedbackLabels") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: contact_center_insights.ListFeedbackLabelsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListFeedbackLabelsResponse: + r"""Call the list feedback labels method over HTTP. + + Args: + request (~.contact_center_insights.ListFeedbackLabelsRequest): + The request object. The request for listing feedback + labels. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListFeedbackLabelsResponse: + The response for listing feedback + labels. + + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseListFeedbackLabels._get_http_options() + ) + request, metadata = self._interceptor.pre_list_feedback_labels( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListFeedbackLabels._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseListFeedbackLabels._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._ListFeedbackLabels._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListFeedbackLabelsResponse() + pb_resp = contact_center_insights.ListFeedbackLabelsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_feedback_labels(resp) + return resp + + class _ListIssueModels( + _BaseContactCenterInsightsRestTransport._BaseListIssueModels, + ContactCenterInsightsRestStub, + ): + def __hash__(self): + return hash("ContactCenterInsightsRestTransport.ListIssueModels") @staticmethod def _get_response( @@ -3552,17 +7464,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetIssueRequest, + request: contact_center_insights.ListIssueModelsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Issue: - r"""Call the get issue method over HTTP. + ) -> contact_center_insights.ListIssueModelsResponse: + r"""Call the list issue models method over HTTP. Args: - request (~.contact_center_insights.GetIssueRequest): - The request object. The request to get an issue. + request (~.contact_center_insights.ListIssueModelsRequest): + The request object. Request to list issue models. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3570,31 +7482,35 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.Issue: - The issue resource. + ~.contact_center_insights.ListIssueModelsResponse: + The response of listing issue models. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_http_options() ) - request, metadata = self._interceptor.pre_get_issue(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_transcoded_request( + request, metadata = self._interceptor.pre_list_issue_models( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._GetIssue._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + ContactCenterInsightsRestTransport._ListIssueModels._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3603,19 +7519,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.Issue() - pb_resp = resources.Issue.pb(resp) + resp = contact_center_insights.ListIssueModelsResponse() + pb_resp = contact_center_insights.ListIssueModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_issue(resp) + resp = self._interceptor.post_list_issue_models(resp) return resp - class _GetIssueModel( - _BaseContactCenterInsightsRestTransport._BaseGetIssueModel, + class _ListIssues( + _BaseContactCenterInsightsRestTransport._BaseListIssues, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetIssueModel") + return hash("ContactCenterInsightsRestTransport.ListIssues") @staticmethod def _get_response( @@ -3641,17 +7557,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetIssueModelRequest, + request: contact_center_insights.ListIssuesRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IssueModel: - r"""Call the get issue model method over HTTP. + ) -> contact_center_insights.ListIssuesResponse: + r"""Call the list issues method over HTTP. Args: - request (~.contact_center_insights.GetIssueModelRequest): - The request object. The request to get an issue model. + request (~.contact_center_insights.ListIssuesRequest): + The request object. Request to list issues. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3659,25 +7575,25 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.IssueModel: - The issue model resource. + ~.contact_center_insights.ListIssuesResponse: + The response of listing issues. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseListIssues._get_http_options() ) - request, metadata = self._interceptor.pre_get_issue_model(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_transcoded_request( + request, metadata = self._interceptor.pre_list_issues(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListIssues._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListIssues._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._GetIssueModel._get_response( + response = ContactCenterInsightsRestTransport._ListIssues._get_response( self._host, metadata, query_params, @@ -3692,19 +7608,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.IssueModel() - pb_resp = resources.IssueModel.pb(resp) + resp = contact_center_insights.ListIssuesResponse() + pb_resp = contact_center_insights.ListIssuesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_issue_model(resp) + resp = self._interceptor.post_list_issues(resp) return resp - class _GetPhraseMatcher( - _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher, + class _ListPhraseMatchers( + _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetPhraseMatcher") + return hash("ContactCenterInsightsRestTransport.ListPhraseMatchers") @staticmethod def _get_response( @@ -3730,18 +7646,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetPhraseMatcherRequest, + request: contact_center_insights.ListPhraseMatchersRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Call the get phrase matcher method over HTTP. + ) -> contact_center_insights.ListPhraseMatchersResponse: + r"""Call the list phrase matchers method over HTTP. Args: - request (~.contact_center_insights.GetPhraseMatcherRequest): - The request object. The request to get a a phrase - matcher. + request (~.contact_center_insights.ListPhraseMatchersRequest): + The request object. Request to list phrase matchers. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3749,28 +7664,30 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.PhraseMatcher: - The phrase matcher resource. + ~.contact_center_insights.ListPhraseMatchersResponse: + The response of listing phrase + matchers. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_http_options() ) - request, metadata = self._interceptor.pre_get_phrase_matcher( + request, metadata = self._interceptor.pre_list_phrase_matchers( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._GetPhraseMatcher._get_response( + ContactCenterInsightsRestTransport._ListPhraseMatchers._get_response( self._host, metadata, query_params, @@ -3786,19 +7703,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.PhraseMatcher() - pb_resp = resources.PhraseMatcher.pb(resp) + resp = contact_center_insights.ListPhraseMatchersResponse() + pb_resp = contact_center_insights.ListPhraseMatchersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_phrase_matcher(resp) + resp = self._interceptor.post_list_phrase_matchers(resp) return resp - class _GetSettings( - _BaseContactCenterInsightsRestTransport._BaseGetSettings, + class _ListQaQuestions( + _BaseContactCenterInsightsRestTransport._BaseListQaQuestions, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetSettings") + return hash("ContactCenterInsightsRestTransport.ListQaQuestions") @staticmethod def _get_response( @@ -3824,18 +7741,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetSettingsRequest, + request: contact_center_insights.ListQaQuestionsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Settings: - r"""Call the get settings method over HTTP. + ) -> contact_center_insights.ListQaQuestionsResponse: + r"""Call the list qa questions method over HTTP. Args: - request (~.contact_center_insights.GetSettingsRequest): - The request object. The request to get project-level - settings. + request (~.contact_center_insights.ListQaQuestionsRequest): + The request object. Request to list QaQuestions. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3843,37 +7759,37 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.Settings: - The CCAI Insights project wide settings. Use these - settings to configure the behavior of Insights. View - these settings with - ```getsettings`` `__ - and change the settings with - ```updateSettings`` `__. + ~.contact_center_insights.ListQaQuestionsResponse: + The response from a ListQaQuestions + request. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseListQaQuestions._get_http_options() ) - request, metadata = self._interceptor.pre_get_settings(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_transcoded_request( + request, metadata = self._interceptor.pre_list_qa_questions( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListQaQuestions._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListQaQuestions._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._GetSettings._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + ContactCenterInsightsRestTransport._ListQaQuestions._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3882,19 +7798,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.Settings() - pb_resp = resources.Settings.pb(resp) + resp = contact_center_insights.ListQaQuestionsResponse() + pb_resp = contact_center_insights.ListQaQuestionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_settings(resp) + resp = self._interceptor.post_list_qa_questions(resp) return resp - class _GetView( - _BaseContactCenterInsightsRestTransport._BaseGetView, + class _ListQaScorecardRevisions( + _BaseContactCenterInsightsRestTransport._BaseListQaScorecardRevisions, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.GetView") + return hash("ContactCenterInsightsRestTransport.ListQaScorecardRevisions") @staticmethod def _get_response( @@ -3920,43 +7836,48 @@ def _get_response( def __call__( self, - request: contact_center_insights.GetViewRequest, + request: contact_center_insights.ListQaScorecardRevisionsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Call the get view method over HTTP. + ) -> contact_center_insights.ListQaScorecardRevisionsResponse: + r"""Call the list qa scorecard + revisions method over HTTP. - Args: - request (~.contact_center_insights.GetViewRequest): - The request object. The request to get a view. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + Args: + request (~.contact_center_insights.ListQaScorecardRevisionsRequest): + The request object. Request to list QaScorecardRevisions + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListQaScorecardRevisionsResponse: + The response from a + ListQaScorecardRevisions request. - Returns: - ~.resources.View: - The View resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseGetView._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseListQaScorecardRevisions._get_http_options() ) - request, metadata = self._interceptor.pre_get_view(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseGetView._get_transcoded_request( + request, metadata = self._interceptor.pre_list_qa_scorecard_revisions( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListQaScorecardRevisions._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseGetView._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListQaScorecardRevisions._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._GetView._get_response( + response = ContactCenterInsightsRestTransport._ListQaScorecardRevisions._get_response( self._host, metadata, query_params, @@ -3971,19 +7892,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.View() - pb_resp = resources.View.pb(resp) + resp = contact_center_insights.ListQaScorecardRevisionsResponse() + pb_resp = contact_center_insights.ListQaScorecardRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_view(resp) + resp = self._interceptor.post_list_qa_scorecard_revisions(resp) return resp - class _ImportIssueModel( - _BaseContactCenterInsightsRestTransport._BaseImportIssueModel, + class _ListQaScorecards( + _BaseContactCenterInsightsRestTransport._BaseListQaScorecards, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ImportIssueModel") + return hash("ContactCenterInsightsRestTransport.ListQaScorecards") @staticmethod def _get_response( @@ -4004,23 +7925,22 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: contact_center_insights.ImportIssueModelRequest, + request: contact_center_insights.ListQaScorecardsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the import issue model method over HTTP. + ) -> contact_center_insights.ListQaScorecardsResponse: + r"""Call the list qa scorecards method over HTTP. Args: - request (~.contact_center_insights.ImportIssueModelRequest): - The request object. Request to import an issue model. + request (~.contact_center_insights.ListQaScorecardsRequest): + The request object. Request to list QaScorecards. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4028,42 +7948,36 @@ def __call__( sent along with the request as metadata. Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + ~.contact_center_insights.ListQaScorecardsResponse: + The response from a ListQaScorecards + request. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseListQaScorecards._get_http_options() ) - request, metadata = self._interceptor.pre_import_issue_model( + request, metadata = self._interceptor.pre_list_qa_scorecards( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListQaScorecards._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListQaScorecards._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._ImportIssueModel._get_response( + ContactCenterInsightsRestTransport._ListQaScorecards._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) ) @@ -4073,17 +7987,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_import_issue_model(resp) + resp = contact_center_insights.ListQaScorecardsResponse() + pb_resp = contact_center_insights.ListQaScorecardsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_qa_scorecards(resp) return resp - class _IngestConversations( - _BaseContactCenterInsightsRestTransport._BaseIngestConversations, + class _ListViews( + _BaseContactCenterInsightsRestTransport._BaseListViews, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.IngestConversations") + return hash("ContactCenterInsightsRestTransport.ListViews") @staticmethod def _get_response( @@ -4104,23 +8020,22 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: contact_center_insights.IngestConversationsRequest, + request: contact_center_insights.ListViewsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the ingest conversations method over HTTP. + ) -> contact_center_insights.ListViewsResponse: + r"""Call the list views method over HTTP. Args: - request (~.contact_center_insights.IngestConversationsRequest): - The request object. The request to ingest conversations. + request (~.contact_center_insights.ListViewsRequest): + The request object. The request to list views. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4128,43 +8043,31 @@ def __call__( sent along with the request as metadata. Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = ( - _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_http_options() - ) - request, metadata = self._interceptor.pre_ingest_conversations( - request, metadata + ~.contact_center_insights.ListViewsResponse: + The response of listing views. + """ + + http_options = ( + _BaseContactCenterInsightsRestTransport._BaseListViews._get_http_options() ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_transcoded_request( + request, metadata = self._interceptor.pre_list_views(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListViews._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseListViews._get_query_params_json( transcoded_request ) # Send the request - response = ( - ContactCenterInsightsRestTransport._IngestConversations._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) + response = ContactCenterInsightsRestTransport._ListViews._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4173,17 +8076,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_ingest_conversations(resp) + resp = contact_center_insights.ListViewsResponse() + pb_resp = contact_center_insights.ListViewsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_views(resp) return resp - class _InitializeEncryptionSpec( - _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec, + class _QueryMetrics( + _BaseContactCenterInsightsRestTransport._BaseQueryMetrics, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.InitializeEncryptionSpec") + return hash("ContactCenterInsightsRestTransport.QueryMetrics") @staticmethod def _get_response( @@ -4210,54 +8115,50 @@ def _get_response( def __call__( self, - request: contact_center_insights.InitializeEncryptionSpecRequest, + request: contact_center_insights.QueryMetricsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: - r"""Call the initialize encryption - spec method over HTTP. + r"""Call the query metrics method over HTTP. - Args: - request (~.contact_center_insights.InitializeEncryptionSpecRequest): - The request object. The request to initialize a - location-level encryption specification. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + Args: + request (~.contact_center_insights.QueryMetricsRequest): + The request object. The request for querying metrics. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_http_options() - ) - request, metadata = self._interceptor.pre_initialize_encryption_spec( - request, metadata + _BaseContactCenterInsightsRestTransport._BaseQueryMetrics._get_http_options() ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_transcoded_request( + request, metadata = self._interceptor.pre_query_metrics(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseQueryMetrics._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseQueryMetrics._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseQueryMetrics._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._InitializeEncryptionSpec._get_response( + response = ContactCenterInsightsRestTransport._QueryMetrics._get_response( self._host, metadata, query_params, @@ -4275,15 +8176,15 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_initialize_encryption_spec(resp) + resp = self._interceptor.post_query_metrics(resp) return resp - class _ListAnalyses( - _BaseContactCenterInsightsRestTransport._BaseListAnalyses, + class _TuneQaScorecardRevision( + _BaseContactCenterInsightsRestTransport._BaseTuneQaScorecardRevision, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ListAnalyses") + return hash("ContactCenterInsightsRestTransport.TuneQaScorecardRevision") @staticmethod def _get_response( @@ -4304,54 +8205,67 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.ListAnalysesRequest, + request: contact_center_insights.TuneQaScorecardRevisionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListAnalysesResponse: - r"""Call the list analyses method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the tune qa scorecard + revision method over HTTP. - Args: - request (~.contact_center_insights.ListAnalysesRequest): - The request object. The request to list analyses. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + Args: + request (~.contact_center_insights.TuneQaScorecardRevisionRequest): + The request object. Request for TuneQaScorecardRevision + endpoint. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. - Returns: - ~.contact_center_insights.ListAnalysesResponse: - The response to list analyses. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseTuneQaScorecardRevision._get_http_options() ) - request, metadata = self._interceptor.pre_list_analyses(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_transcoded_request( + request, metadata = self._interceptor.pre_tune_qa_scorecard_revision( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseTuneQaScorecardRevision._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseTuneQaScorecardRevision._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseTuneQaScorecardRevision._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._ListAnalyses._get_response( + response = ContactCenterInsightsRestTransport._TuneQaScorecardRevision._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4360,19 +8274,17 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.ListAnalysesResponse() - pb_resp = contact_center_insights.ListAnalysesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_analyses(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_tune_qa_scorecard_revision(resp) return resp - class _ListConversations( - _BaseContactCenterInsightsRestTransport._BaseListConversations, + class _UndeployIssueModel( + _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ListConversations") + return hash("ContactCenterInsightsRestTransport.UndeployIssueModel") @staticmethod def _get_response( @@ -4393,22 +8305,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.ListConversationsRequest, + request: contact_center_insights.UndeployIssueModelRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListConversationsResponse: - r"""Call the list conversations method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the undeploy issue model method over HTTP. Args: - request (~.contact_center_insights.ListConversationsRequest): - The request object. Request to list conversations. + request (~.contact_center_insights.UndeployIssueModelRequest): + The request object. The request to undeploy an issue + model. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4416,36 +8330,42 @@ def __call__( sent along with the request as metadata. Returns: - ~.contact_center_insights.ListConversationsResponse: - The response of listing - conversations. + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseListConversations._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_http_options() ) - request, metadata = self._interceptor.pre_list_conversations( + request, metadata = self._interceptor.pre_undeploy_issue_model( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListConversations._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseListConversations._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._ListConversations._get_response( + ContactCenterInsightsRestTransport._UndeployIssueModel._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) ) @@ -4455,19 +8375,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.ListConversationsResponse() - pb_resp = contact_center_insights.ListConversationsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_conversations(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_issue_model(resp) return resp - class _ListIssueModels( - _BaseContactCenterInsightsRestTransport._BaseListIssueModels, + class _UndeployQaScorecardRevision( + _BaseContactCenterInsightsRestTransport._BaseUndeployQaScorecardRevision, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ListIssueModels") + return hash( + "ContactCenterInsightsRestTransport.UndeployQaScorecardRevision" + ) @staticmethod def _get_response( @@ -4488,58 +8408,74 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.ListIssueModelsRequest, + request: contact_center_insights.UndeployQaScorecardRevisionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListIssueModelsResponse: - r"""Call the list issue models method over HTTP. + ) -> resources.QaScorecardRevision: + r"""Call the undeploy qa scorecard + revision method over HTTP. - Args: - request (~.contact_center_insights.ListIssueModelsRequest): - The request object. Request to list issue models. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + Args: + request (~.contact_center_insights.UndeployQaScorecardRevisionRequest): + The request object. The request to undeploy a + QaScorecardRevision + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.QaScorecardRevision: + A revision of a QaScorecard. + + Modifying published scorecard fields + would invalidate existing scorecard + results — the questions may have + changed, or the score weighting will + make existing scores impossible to + understand. So changes must create a new + revision, rather than modifying the + existing resource. - Returns: - ~.contact_center_insights.ListIssueModelsResponse: - The response of listing issue models. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUndeployQaScorecardRevision._get_http_options() ) - request, metadata = self._interceptor.pre_list_issue_models( + request, metadata = self._interceptor.pre_undeploy_qa_scorecard_revision( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUndeployQaScorecardRevision._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseUndeployQaScorecardRevision._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUndeployQaScorecardRevision._get_query_params_json( transcoded_request ) # Send the request - response = ( - ContactCenterInsightsRestTransport._ListIssueModels._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - ) + response = ContactCenterInsightsRestTransport._UndeployQaScorecardRevision._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4548,19 +8484,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.ListIssueModelsResponse() - pb_resp = contact_center_insights.ListIssueModelsResponse.pb(resp) + resp = resources.QaScorecardRevision() + pb_resp = resources.QaScorecardRevision.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_issue_models(resp) + resp = self._interceptor.post_undeploy_qa_scorecard_revision(resp) return resp - class _ListIssues( - _BaseContactCenterInsightsRestTransport._BaseListIssues, + class _UpdateAnalysisRule( + _BaseContactCenterInsightsRestTransport._BaseUpdateAnalysisRule, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ListIssues") + return hash("ContactCenterInsightsRestTransport.UpdateAnalysisRule") @staticmethod def _get_response( @@ -4581,22 +8517,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.ListIssuesRequest, + request: contact_center_insights.UpdateAnalysisRuleRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListIssuesResponse: - r"""Call the list issues method over HTTP. + ) -> resources.AnalysisRule: + r"""Call the update analysis rule method over HTTP. Args: - request (~.contact_center_insights.ListIssuesRequest): - The request object. Request to list issues. + request (~.contact_center_insights.UpdateAnalysisRuleRequest): + The request object. The request to update a analysis + rule. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4604,31 +8542,50 @@ def __call__( sent along with the request as metadata. Returns: - ~.contact_center_insights.ListIssuesResponse: - The response of listing issues. + ~.resources.AnalysisRule: + The CCAI Insights project wide + analysis rule. This rule will be applied + to all conversations that match the + filter defined in the rule. For a + conversation matches the filter, the + annotators specified in the rule will be + run. If a conversation matches multiple + rules, a union of all the annotators + will be run. One project can have + multiple analysis rules. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseListIssues._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUpdateAnalysisRule._get_http_options() ) - request, metadata = self._interceptor.pre_list_issues(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListIssues._get_transcoded_request( + request, metadata = self._interceptor.pre_update_analysis_rule( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateAnalysisRule._get_transcoded_request( http_options, request ) - # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseListIssues._get_query_params_json( + body = _BaseContactCenterInsightsRestTransport._BaseUpdateAnalysisRule._get_request_body_json( transcoded_request ) - - # Send the request - response = ContactCenterInsightsRestTransport._ListIssues._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + + # Jsonify the query params + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateAnalysisRule._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ( + ContactCenterInsightsRestTransport._UpdateAnalysisRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4637,19 +8594,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.ListIssuesResponse() - pb_resp = contact_center_insights.ListIssuesResponse.pb(resp) + resp = resources.AnalysisRule() + pb_resp = resources.AnalysisRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_issues(resp) + resp = self._interceptor.post_update_analysis_rule(resp) return resp - class _ListPhraseMatchers( - _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers, + class _UpdateConversation( + _BaseContactCenterInsightsRestTransport._BaseUpdateConversation, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ListPhraseMatchers") + return hash("ContactCenterInsightsRestTransport.UpdateConversation") @staticmethod def _get_response( @@ -4670,22 +8627,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.ListPhraseMatchersRequest, + request: contact_center_insights.UpdateConversationRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListPhraseMatchersResponse: - r"""Call the list phrase matchers method over HTTP. + ) -> resources.Conversation: + r"""Call the update conversation method over HTTP. Args: - request (~.contact_center_insights.ListPhraseMatchersRequest): - The request object. Request to list phrase matchers. + request (~.contact_center_insights.UpdateConversationRequest): + The request object. The request to update a conversation. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4693,36 +8651,39 @@ def __call__( sent along with the request as metadata. Returns: - ~.contact_center_insights.ListPhraseMatchersResponse: - The response of listing phrase - matchers. - + ~.resources.Conversation: + The conversation resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_http_options() ) - request, metadata = self._interceptor.pre_list_phrase_matchers( + request, metadata = self._interceptor.pre_update_conversation( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._ListPhraseMatchers._get_response( + ContactCenterInsightsRestTransport._UpdateConversation._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) ) @@ -4732,19 +8693,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.ListPhraseMatchersResponse() - pb_resp = contact_center_insights.ListPhraseMatchersResponse.pb(resp) + resp = resources.Conversation() + pb_resp = resources.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_phrase_matchers(resp) + resp = self._interceptor.post_update_conversation(resp) return resp - class _ListViews( - _BaseContactCenterInsightsRestTransport._BaseListViews, + class _UpdateFeedbackLabel( + _BaseContactCenterInsightsRestTransport._BaseUpdateFeedbackLabel, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.ListViews") + return hash("ContactCenterInsightsRestTransport.UpdateFeedbackLabel") @staticmethod def _get_response( @@ -4765,22 +8726,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: contact_center_insights.ListViewsRequest, + request: contact_center_insights.UpdateFeedbackLabelRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListViewsResponse: - r"""Call the list views method over HTTP. + ) -> resources.FeedbackLabel: + r"""Call the update feedback label method over HTTP. Args: - request (~.contact_center_insights.ListViewsRequest): - The request object. The request to list views. + request (~.contact_center_insights.UpdateFeedbackLabelRequest): + The request object. The request for updating a feedback + label. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4788,31 +8751,42 @@ def __call__( sent along with the request as metadata. Returns: - ~.contact_center_insights.ListViewsResponse: - The response of listing views. + ~.resources.FeedbackLabel: + Represents a conversation, resource, + and label provided by the user. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseListViews._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUpdateFeedbackLabel._get_http_options() ) - request, metadata = self._interceptor.pre_list_views(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseListViews._get_transcoded_request( + request, metadata = self._interceptor.pre_update_feedback_label( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateFeedbackLabel._get_transcoded_request( http_options, request ) + body = _BaseContactCenterInsightsRestTransport._BaseUpdateFeedbackLabel._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseListViews._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateFeedbackLabel._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._ListViews._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + ContactCenterInsightsRestTransport._UpdateFeedbackLabel._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4821,19 +8795,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = contact_center_insights.ListViewsResponse() - pb_resp = contact_center_insights.ListViewsResponse.pb(resp) + resp = resources.FeedbackLabel() + pb_resp = resources.FeedbackLabel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_views(resp) + resp = self._interceptor.post_update_feedback_label(resp) return resp - class _UndeployIssueModel( - _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel, + class _UpdateIssue( + _BaseContactCenterInsightsRestTransport._BaseUpdateIssue, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.UndeployIssueModel") + return hash("ContactCenterInsightsRestTransport.UpdateIssue") @staticmethod def _get_response( @@ -4860,18 +8834,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.UndeployIssueModelRequest, + request: contact_center_insights.UpdateIssueRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the undeploy issue model method over HTTP. + ) -> resources.Issue: + r"""Call the update issue method over HTTP. Args: - request (~.contact_center_insights.UndeployIssueModelRequest): - The request object. The request to undeploy an issue - model. + request (~.contact_center_insights.UpdateIssueRequest): + The request object. The request to update an issue. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4879,43 +8852,36 @@ def __call__( sent along with the request as metadata. Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - + ~.resources.Issue: + The issue resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_http_options() - ) - request, metadata = self._interceptor.pre_undeploy_issue_model( - request, metadata + _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_http_options() ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_transcoded_request( + request, metadata = self._interceptor.pre_update_issue(request, metadata) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_query_params_json( transcoded_request ) # Send the request - response = ( - ContactCenterInsightsRestTransport._UndeployIssueModel._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) + response = ContactCenterInsightsRestTransport._UpdateIssue._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4924,17 +8890,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_undeploy_issue_model(resp) + resp = resources.Issue() + pb_resp = resources.Issue.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_issue(resp) return resp - class _UpdateConversation( - _BaseContactCenterInsightsRestTransport._BaseUpdateConversation, + class _UpdateIssueModel( + _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.UpdateConversation") + return hash("ContactCenterInsightsRestTransport.UpdateIssueModel") @staticmethod def _get_response( @@ -4961,17 +8929,17 @@ def _get_response( def __call__( self, - request: contact_center_insights.UpdateConversationRequest, + request: contact_center_insights.UpdateIssueModelRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Call the update conversation method over HTTP. + ) -> resources.IssueModel: + r"""Call the update issue model method over HTTP. Args: - request (~.contact_center_insights.UpdateConversationRequest): - The request object. The request to update a conversation. + request (~.contact_center_insights.UpdateIssueModelRequest): + The request object. The request to update an issue model. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4979,32 +8947,32 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.Conversation: - The conversation resource. + ~.resources.IssueModel: + The issue model resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_http_options() ) - request, metadata = self._interceptor.pre_update_conversation( + request, metadata = self._interceptor.pre_update_issue_model( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._UpdateConversation._get_response( + ContactCenterInsightsRestTransport._UpdateIssueModel._get_response( self._host, metadata, query_params, @@ -5021,19 +8989,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.Conversation() - pb_resp = resources.Conversation.pb(resp) + resp = resources.IssueModel() + pb_resp = resources.IssueModel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_conversation(resp) + resp = self._interceptor.post_update_issue_model(resp) return resp - class _UpdateIssue( - _BaseContactCenterInsightsRestTransport._BaseUpdateIssue, + class _UpdatePhraseMatcher( + _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.UpdateIssue") + return hash("ContactCenterInsightsRestTransport.UpdatePhraseMatcher") @staticmethod def _get_response( @@ -5060,17 +9028,18 @@ def _get_response( def __call__( self, - request: contact_center_insights.UpdateIssueRequest, + request: contact_center_insights.UpdatePhraseMatcherRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Issue: - r"""Call the update issue method over HTTP. + ) -> resources.PhraseMatcher: + r"""Call the update phrase matcher method over HTTP. Args: - request (~.contact_center_insights.UpdateIssueRequest): - The request object. The request to update an issue. + request (~.contact_center_insights.UpdatePhraseMatcherRequest): + The request object. The request to update a phrase + matcher. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -5078,36 +9047,40 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.Issue: - The issue resource. + ~.resources.PhraseMatcher: + The phrase matcher resource. """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_http_options() ) - request, metadata = self._interceptor.pre_update_issue(request, metadata) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_transcoded_request( + request, metadata = self._interceptor.pre_update_phrase_matcher( + request, metadata + ) + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_query_params_json( transcoded_request ) # Send the request - response = ContactCenterInsightsRestTransport._UpdateIssue._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, + response = ( + ContactCenterInsightsRestTransport._UpdatePhraseMatcher._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -5116,19 +9089,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.Issue() - pb_resp = resources.Issue.pb(resp) + resp = resources.PhraseMatcher() + pb_resp = resources.PhraseMatcher.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_issue(resp) + resp = self._interceptor.post_update_phrase_matcher(resp) return resp - class _UpdateIssueModel( - _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel, + class _UpdateQaQuestion( + _BaseContactCenterInsightsRestTransport._BaseUpdateQaQuestion, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.UpdateIssueModel") + return hash("ContactCenterInsightsRestTransport.UpdateQaQuestion") @staticmethod def _get_response( @@ -5155,17 +9128,18 @@ def _get_response( def __call__( self, - request: contact_center_insights.UpdateIssueModelRequest, + request: contact_center_insights.UpdateQaQuestionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IssueModel: - r"""Call the update issue model method over HTTP. + ) -> resources.QaQuestion: + r"""Call the update qa question method over HTTP. Args: - request (~.contact_center_insights.UpdateIssueModelRequest): - The request object. The request to update an issue model. + request (~.contact_center_insights.UpdateQaQuestionRequest): + The request object. The request for updating a + QaQuestion. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -5173,32 +9147,34 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.IssueModel: - The issue model resource. + ~.resources.QaQuestion: + A single question to be scored by the + Insights QA feature. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUpdateQaQuestion._get_http_options() ) - request, metadata = self._interceptor.pre_update_issue_model( + request, metadata = self._interceptor.pre_update_qa_question( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateQaQuestion._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseUpdateQaQuestion._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateQaQuestion._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._UpdateIssueModel._get_response( + ContactCenterInsightsRestTransport._UpdateQaQuestion._get_response( self._host, metadata, query_params, @@ -5215,19 +9191,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.IssueModel() - pb_resp = resources.IssueModel.pb(resp) + resp = resources.QaQuestion() + pb_resp = resources.QaQuestion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_issue_model(resp) + resp = self._interceptor.post_update_qa_question(resp) return resp - class _UpdatePhraseMatcher( - _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher, + class _UpdateQaScorecard( + _BaseContactCenterInsightsRestTransport._BaseUpdateQaScorecard, ContactCenterInsightsRestStub, ): def __hash__(self): - return hash("ContactCenterInsightsRestTransport.UpdatePhraseMatcher") + return hash("ContactCenterInsightsRestTransport.UpdateQaScorecard") @staticmethod def _get_response( @@ -5254,18 +9230,18 @@ def _get_response( def __call__( self, - request: contact_center_insights.UpdatePhraseMatcherRequest, + request: contact_center_insights.UpdateQaScorecardRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Call the update phrase matcher method over HTTP. + ) -> resources.QaScorecard: + r"""Call the update qa scorecard method over HTTP. Args: - request (~.contact_center_insights.UpdatePhraseMatcherRequest): - The request object. The request to update a phrase - matcher. + request (~.contact_center_insights.UpdateQaScorecardRequest): + The request object. The request for updating a + QaScorecard. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -5273,32 +9249,35 @@ def __call__( sent along with the request as metadata. Returns: - ~.resources.PhraseMatcher: - The phrase matcher resource. + ~.resources.QaScorecard: + A QaScorecard represents a collection + of questions to be scored during + analysis. + """ http_options = ( - _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_http_options() + _BaseContactCenterInsightsRestTransport._BaseUpdateQaScorecard._get_http_options() ) - request, metadata = self._interceptor.pre_update_phrase_matcher( + request, metadata = self._interceptor.pre_update_qa_scorecard( request, metadata ) - transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_transcoded_request( + transcoded_request = _BaseContactCenterInsightsRestTransport._BaseUpdateQaScorecard._get_transcoded_request( http_options, request ) - body = _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_request_body_json( + body = _BaseContactCenterInsightsRestTransport._BaseUpdateQaScorecard._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_query_params_json( + query_params = _BaseContactCenterInsightsRestTransport._BaseUpdateQaScorecard._get_query_params_json( transcoded_request ) # Send the request response = ( - ContactCenterInsightsRestTransport._UpdatePhraseMatcher._get_response( + ContactCenterInsightsRestTransport._UpdateQaScorecard._get_response( self._host, metadata, query_params, @@ -5315,11 +9294,11 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.PhraseMatcher() - pb_resp = resources.PhraseMatcher.pb(resp) + resp = resources.QaScorecard() + pb_resp = resources.QaScorecard.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_phrase_matcher(resp) + resp = self._interceptor.post_update_qa_scorecard(resp) return resp class _UpdateSettings( @@ -5641,6 +9620,28 @@ def bulk_delete_conversations( # In C++ this would require a dynamic_cast return self._BulkDeleteConversations(self._session, self._host, self._interceptor) # type: ignore + @property + def bulk_download_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkDownloadFeedbackLabelsRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BulkDownloadFeedbackLabels(self._session, self._host, self._interceptor) # type: ignore + + @property + def bulk_upload_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.BulkUploadFeedbackLabelsRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BulkUploadFeedbackLabels(self._session, self._host, self._interceptor) # type: ignore + @property def calculate_issue_model_stats( self, @@ -5673,6 +9674,16 @@ def create_analysis( # In C++ this would require a dynamic_cast return self._CreateAnalysis(self._session, self._host, self._interceptor) # type: ignore + @property + def create_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.CreateAnalysisRuleRequest], resources.AnalysisRule + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateAnalysisRule(self._session, self._host, self._interceptor) # type: ignore + @property def create_conversation( self, @@ -5683,6 +9694,16 @@ def create_conversation( # In C++ this would require a dynamic_cast return self._CreateConversation(self._session, self._host, self._interceptor) # type: ignore + @property + def create_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.CreateFeedbackLabelRequest], resources.FeedbackLabel + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateFeedbackLabel(self._session, self._host, self._interceptor) # type: ignore + @property def create_issue_model( self, @@ -5703,6 +9724,37 @@ def create_phrase_matcher( # In C++ this would require a dynamic_cast return self._CreatePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + @property + def create_qa_question( + self, + ) -> Callable[ + [contact_center_insights.CreateQaQuestionRequest], resources.QaQuestion + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateQaQuestion(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRequest], resources.QaScorecard + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateQaScorecard(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.CreateQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateQaScorecardRevision(self._session, self._host, self._interceptor) # type: ignore + @property def create_view( self, @@ -5719,6 +9771,14 @@ def delete_analysis( # In C++ this would require a dynamic_cast return self._DeleteAnalysis(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_analysis_rule( + self, + ) -> Callable[[contact_center_insights.DeleteAnalysisRuleRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteAnalysisRule(self._session, self._host, self._interceptor) # type: ignore + @property def delete_conversation( self, @@ -5727,6 +9787,16 @@ def delete_conversation( # In C++ this would require a dynamic_cast return self._DeleteConversation(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.DeleteFeedbackLabelRequest], empty_pb2.Empty + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteFeedbackLabel(self._session, self._host, self._interceptor) # type: ignore + @property def delete_issue( self, @@ -5755,6 +9825,32 @@ def delete_phrase_matcher( # In C++ this would require a dynamic_cast return self._DeletePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_qa_question( + self, + ) -> Callable[[contact_center_insights.DeleteQaQuestionRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteQaQuestion(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_qa_scorecard( + self, + ) -> Callable[[contact_center_insights.DeleteQaScorecardRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteQaScorecard(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.DeleteQaScorecardRevisionRequest], empty_pb2.Empty + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteQaScorecardRevision(self._session, self._host, self._interceptor) # type: ignore + @property def delete_view( self, @@ -5773,6 +9869,17 @@ def deploy_issue_model( # In C++ this would require a dynamic_cast return self._DeployIssueModel(self._session, self._host, self._interceptor) # type: ignore + @property + def deploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.DeployQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeployQaScorecardRevision(self._session, self._host, self._interceptor) # type: ignore + @property def export_insights_data( self, @@ -5801,6 +9908,16 @@ def get_analysis( # In C++ this would require a dynamic_cast return self._GetAnalysis(self._session, self._host, self._interceptor) # type: ignore + @property + def get_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.GetAnalysisRuleRequest], resources.AnalysisRule + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetAnalysisRule(self._session, self._host, self._interceptor) # type: ignore + @property def get_conversation( self, @@ -5821,6 +9938,16 @@ def get_encryption_spec( # In C++ this would require a dynamic_cast return self._GetEncryptionSpec(self._session, self._host, self._interceptor) # type: ignore + @property + def get_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.GetFeedbackLabelRequest], resources.FeedbackLabel + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetFeedbackLabel(self._session, self._host, self._interceptor) # type: ignore + @property def get_issue( self, @@ -5847,6 +9974,35 @@ def get_phrase_matcher( # In C++ this would require a dynamic_cast return self._GetPhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + @property + def get_qa_question( + self, + ) -> Callable[[contact_center_insights.GetQaQuestionRequest], resources.QaQuestion]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetQaQuestion(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRequest], resources.QaScorecard + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetQaScorecard(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.GetQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetQaScorecardRevision(self._session, self._host, self._interceptor) # type: ignore + @property def get_settings( self, @@ -5894,6 +10050,17 @@ def initialize_encryption_spec( # In C++ this would require a dynamic_cast return self._InitializeEncryptionSpec(self._session, self._host, self._interceptor) # type: ignore + @property + def list_all_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.ListAllFeedbackLabelsRequest], + contact_center_insights.ListAllFeedbackLabelsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListAllFeedbackLabels(self._session, self._host, self._interceptor) # type: ignore + @property def list_analyses( self, @@ -5905,6 +10072,17 @@ def list_analyses( # In C++ this would require a dynamic_cast return self._ListAnalyses(self._session, self._host, self._interceptor) # type: ignore + @property + def list_analysis_rules( + self, + ) -> Callable[ + [contact_center_insights.ListAnalysisRulesRequest], + contact_center_insights.ListAnalysisRulesResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListAnalysisRules(self._session, self._host, self._interceptor) # type: ignore + @property def list_conversations( self, @@ -5916,6 +10094,17 @@ def list_conversations( # In C++ this would require a dynamic_cast return self._ListConversations(self._session, self._host, self._interceptor) # type: ignore + @property + def list_feedback_labels( + self, + ) -> Callable[ + [contact_center_insights.ListFeedbackLabelsRequest], + contact_center_insights.ListFeedbackLabelsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListFeedbackLabels(self._session, self._host, self._interceptor) # type: ignore + @property def list_issue_models( self, @@ -5949,6 +10138,39 @@ def list_phrase_matchers( # In C++ this would require a dynamic_cast return self._ListPhraseMatchers(self._session, self._host, self._interceptor) # type: ignore + @property + def list_qa_questions( + self, + ) -> Callable[ + [contact_center_insights.ListQaQuestionsRequest], + contact_center_insights.ListQaQuestionsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListQaQuestions(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_qa_scorecard_revisions( + self, + ) -> Callable[ + [contact_center_insights.ListQaScorecardRevisionsRequest], + contact_center_insights.ListQaScorecardRevisionsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListQaScorecardRevisions(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_qa_scorecards( + self, + ) -> Callable[ + [contact_center_insights.ListQaScorecardsRequest], + contact_center_insights.ListQaScorecardsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListQaScorecards(self._session, self._host, self._interceptor) # type: ignore + @property def list_views( self, @@ -5960,6 +10182,27 @@ def list_views( # In C++ this would require a dynamic_cast return self._ListViews(self._session, self._host, self._interceptor) # type: ignore + @property + def query_metrics( + self, + ) -> Callable[ + [contact_center_insights.QueryMetricsRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._QueryMetrics(self._session, self._host, self._interceptor) # type: ignore + + @property + def tune_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.TuneQaScorecardRevisionRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._TuneQaScorecardRevision(self._session, self._host, self._interceptor) # type: ignore + @property def undeploy_issue_model( self, @@ -5970,6 +10213,27 @@ def undeploy_issue_model( # In C++ this would require a dynamic_cast return self._UndeployIssueModel(self._session, self._host, self._interceptor) # type: ignore + @property + def undeploy_qa_scorecard_revision( + self, + ) -> Callable[ + [contact_center_insights.UndeployQaScorecardRevisionRequest], + resources.QaScorecardRevision, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UndeployQaScorecardRevision(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_analysis_rule( + self, + ) -> Callable[ + [contact_center_insights.UpdateAnalysisRuleRequest], resources.AnalysisRule + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateAnalysisRule(self._session, self._host, self._interceptor) # type: ignore + @property def update_conversation( self, @@ -5980,6 +10244,16 @@ def update_conversation( # In C++ this would require a dynamic_cast return self._UpdateConversation(self._session, self._host, self._interceptor) # type: ignore + @property + def update_feedback_label( + self, + ) -> Callable[ + [contact_center_insights.UpdateFeedbackLabelRequest], resources.FeedbackLabel + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateFeedbackLabel(self._session, self._host, self._interceptor) # type: ignore + @property def update_issue( self, @@ -6008,6 +10282,26 @@ def update_phrase_matcher( # In C++ this would require a dynamic_cast return self._UpdatePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + @property + def update_qa_question( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaQuestionRequest], resources.QaQuestion + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateQaQuestion(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_qa_scorecard( + self, + ) -> Callable[ + [contact_center_insights.UpdateQaScorecardRequest], resources.QaScorecard + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateQaScorecard(self._session, self._host, self._interceptor) # type: ignore + @property def update_settings( self, diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest_base.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest_base.py index 57af3a681a0d..306fa9225329 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest_base.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest_base.py @@ -18,6 +18,8 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1, path_template +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import json_format @@ -210,7 +212,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCalculateIssueModelStats: + class _BaseBulkDownloadFeedbackLabels: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -228,20 +230,30 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}:bulkDownloadFeedbackLabels", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.CalculateIssueModelStatsRequest.pb( + pb_request = contact_center_insights.BulkDownloadFeedbackLabelsRequest.pb( request ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -251,7 +263,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseBulkDownloadFeedbackLabels._get_unset_required_fields( query_params ) ) @@ -259,7 +271,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCalculateStats: + class _BaseBulkUploadFeedbackLabels: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -277,18 +289,30 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{location=projects/*/locations/*}/conversations:calculateStats", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}:bulkUploadFeedbackLabels", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.CalculateStatsRequest.pb(request) + pb_request = contact_center_insights.BulkUploadFeedbackLabelsRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -298,7 +322,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseBulkUploadFeedbackLabels._get_unset_required_fields( query_params ) ) @@ -306,7 +330,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCreateAnalysis: + class _BaseCalculateIssueModelStats: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -324,28 +348,20 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*/conversations/*}/analyses", - "body": "analysis", + "method": "get", + "uri": "/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.CreateAnalysisRequest.pb(request) + pb_request = contact_center_insights.CalculateIssueModelStatsRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -355,7 +371,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCalculateIssueModelStats._get_unset_required_fields( query_params ) ) @@ -363,7 +379,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCreateConversation: + class _BaseCalculateStats: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -381,28 +397,18 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/conversations", - "body": "conversation", + "method": "get", + "uri": "/v1/{location=projects/*/locations/*}/conversations:calculateStats", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.CreateConversationRequest.pb(request) + pb_request = contact_center_insights.CalculateStatsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -412,7 +418,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCalculateStats._get_unset_required_fields( query_params ) ) @@ -420,7 +426,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCreateIssueModel: + class _BaseCreateAnalysis: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -439,15 +445,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/issueModels", - "body": "issue_model", + "uri": "/v1/{parent=projects/*/locations/*/conversations/*}/analyses", + "body": "analysis", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.CreateIssueModelRequest.pb(request) + pb_request = contact_center_insights.CreateAnalysisRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -469,7 +475,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateAnalysis._get_unset_required_fields( query_params ) ) @@ -477,7 +483,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCreatePhraseMatcher: + class _BaseCreateAnalysisRule: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -496,15 +502,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/phraseMatchers", - "body": "phrase_matcher", + "uri": "/v1/{parent=projects/*/locations/*}/analysisRules", + "body": "analysis_rule", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.CreatePhraseMatcherRequest.pb(request) + pb_request = contact_center_insights.CreateAnalysisRuleRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -526,7 +532,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateAnalysisRule._get_unset_required_fields( query_params ) ) @@ -534,7 +540,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCreateView: + class _BaseCreateConversation: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -553,15 +559,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/views", - "body": "view", + "uri": "/v1/{parent=projects/*/locations/*}/conversations", + "body": "conversation", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.CreateViewRequest.pb(request) + pb_request = contact_center_insights.CreateConversationRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -583,7 +589,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseCreateView._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateConversation._get_unset_required_fields( query_params ) ) @@ -591,7 +597,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteAnalysis: + class _BaseCreateFeedbackLabel: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -609,18 +615,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/conversations/*/analyses/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/conversations/*}/feedbackLabels", + "body": "feedback_label", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.DeleteAnalysisRequest.pb(request) + pb_request = contact_center_insights.CreateFeedbackLabelRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -630,7 +646,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateFeedbackLabel._get_unset_required_fields( query_params ) ) @@ -638,7 +654,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteConversation: + class _BaseCreateIssueModel: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -656,18 +672,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/conversations/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/issueModels", + "body": "issue_model", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.DeleteConversationRequest.pb(request) + pb_request = contact_center_insights.CreateIssueModelRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -677,7 +703,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateIssueModel._get_unset_required_fields( query_params ) ) @@ -685,7 +711,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteIssue: + class _BaseCreatePhraseMatcher: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -703,18 +729,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/issueModels/*/issues/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/phraseMatchers", + "body": "phrase_matcher", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.DeleteIssueRequest.pb(request) + pb_request = contact_center_insights.CreatePhraseMatcherRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -724,7 +760,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreatePhraseMatcher._get_unset_required_fields( query_params ) ) @@ -732,7 +768,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteIssueModel: + class _BaseCreateQaQuestion: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -750,18 +786,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/issueModels/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/qaScorecards/*/revisions/*}/qaQuestions", + "body": "qa_question", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.DeleteIssueModelRequest.pb(request) + pb_request = contact_center_insights.CreateQaQuestionRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -771,7 +817,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateQaQuestion._get_unset_required_fields( query_params ) ) @@ -779,7 +825,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeletePhraseMatcher: + class _BaseCreateQaScorecard: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -797,18 +843,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/phraseMatchers/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/qaScorecards", + "body": "qa_scorecard", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.DeletePhraseMatcherRequest.pb(request) + pb_request = contact_center_insights.CreateQaScorecardRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -818,7 +874,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecard._get_unset_required_fields( query_params ) ) @@ -826,7 +882,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteView: + class _BaseCreateQaScorecardRevision: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -844,18 +900,30 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/views/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/qaScorecards/*}/revisions", + "body": "qa_scorecard_revision", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.DeleteViewRequest.pb(request) + pb_request = contact_center_insights.CreateQaScorecardRevisionRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -865,7 +933,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateQaScorecardRevision._get_unset_required_fields( query_params ) ) @@ -873,7 +941,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeployIssueModel: + class _BaseCreateView: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -892,15 +960,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1/{name=projects/*/locations/*/issueModels/*}:deploy", - "body": "*", + "uri": "/v1/{parent=projects/*/locations/*}/views", + "body": "view", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.DeployIssueModelRequest.pb(request) + pb_request = contact_center_insights.CreateViewRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -922,7 +990,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseCreateView._get_unset_required_fields( query_params ) ) @@ -930,7 +998,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseExportInsightsData: + class _BaseDeleteAnalysis: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -948,28 +1016,18 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/insightsdata:export", - "body": "*", + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/conversations/*/analyses/*}", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ExportInsightsDataRequest.pb(request) + pb_request = contact_center_insights.DeleteAnalysisRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -979,7 +1037,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysis._get_unset_required_fields( query_params ) ) @@ -987,7 +1045,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseExportIssueModel: + class _BaseDeleteAnalysisRule: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1005,27 +1063,1554 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{name=projects/*/locations/*/issueModels/*}:export", - "body": "*", + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/analysisRules/*}", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ExportIssueModelRequest.pb(request) + pb_request = contact_center_insights.DeleteAnalysisRuleRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) ) - return body + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteAnalysisRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteConversation: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/conversations/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteConversationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteConversation._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteFeedbackLabel: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/conversations/*/feedbackLabels/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteFeedbackLabelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteFeedbackLabel._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteIssue: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/issueModels/*/issues/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteIssue._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteIssueModel: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/issueModels/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteIssueModel._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeletePhraseMatcher: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/phraseMatchers/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeletePhraseMatcherRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeletePhraseMatcher._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteQaQuestion: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*/qaQuestions/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteQaQuestionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaQuestion._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteQaScorecard: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteQaScorecardRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecard._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteQaScorecardRevision: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteQaScorecardRevisionRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteQaScorecardRevision._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteView: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/views/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeleteViewRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeleteView._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeployIssueModel: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/issueModels/*}:deploy", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeployIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeployIssueModel._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeployQaScorecardRevision: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*}:deploy", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.DeployQaScorecardRevisionRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseDeployQaScorecardRevision._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseExportInsightsData: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/insightsdata:export", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.ExportInsightsDataRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseExportInsightsData._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseExportIssueModel: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/issueModels/*}:export", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.ExportIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetAnalysis: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/conversations/*/analyses/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetAnalysisRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetAnalysisRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/analysisRules/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetAnalysisRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetAnalysisRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetConversation: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/conversations/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetConversationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetEncryptionSpec: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/encryptionSpec}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetEncryptionSpecRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetFeedbackLabel: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/conversations/*/feedbackLabels/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetFeedbackLabelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetFeedbackLabel._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetIssue: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/issueModels/*/issues/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetIssueModel: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/issueModels/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetPhraseMatcher: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/phraseMatchers/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetPhraseMatcherRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetQaQuestion: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*/qaQuestions/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetQaQuestionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetQaQuestion._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetQaScorecard: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetQaScorecardRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetQaScorecard._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetQaScorecardRevision: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetQaScorecardRevisionRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetQaScorecardRevision._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetSettings: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/settings}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetSettingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetView: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/views/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.GetViewRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseGetView._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseImportIssueModel: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/issueModels:import", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.ImportIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseIngestConversations: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/conversations:ingest", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.IngestConversationsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseInitializeEncryptionSpec: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{encryption_spec.name=projects/*/locations/*/encryptionSpec}:initialize", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.InitializeEncryptionSpecRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListAllFeedbackLabels: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}:listAllFeedbackLabels", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.ListAllFeedbackLabelsRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseContactCenterInsightsRestTransport._BaseListAllFeedbackLabels._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListAnalyses: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/conversations/*}/analyses", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = contact_center_insights.ListAnalysesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request @staticmethod def _get_query_params_json(transcoded_request): @@ -1036,7 +2621,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseExportIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_unset_required_fields( query_params ) ) @@ -1044,7 +2629,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetAnalysis: + class _BaseListAnalysisRules: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1063,14 +2648,14 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/conversations/*/analyses/*}", + "uri": "/v1/{parent=projects/*/locations/*}/analysisRules", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetAnalysisRequest.pb(request) + pb_request = contact_center_insights.ListAnalysisRulesRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1083,7 +2668,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetAnalysis._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListAnalysisRules._get_unset_required_fields( query_params ) ) @@ -1091,7 +2676,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetConversation: + class _BaseListConversations: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1110,14 +2695,14 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/conversations/*}", + "uri": "/v1/{parent=projects/*/locations/*}/conversations", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetConversationRequest.pb(request) + pb_request = contact_center_insights.ListConversationsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1130,7 +2715,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetConversation._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListConversations._get_unset_required_fields( query_params ) ) @@ -1138,7 +2723,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetEncryptionSpec: + class _BaseListFeedbackLabels: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1157,14 +2742,14 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/encryptionSpec}", + "uri": "/v1/{parent=projects/*/locations/*/conversations/*}/feedbackLabels", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetEncryptionSpecRequest.pb(request) + pb_request = contact_center_insights.ListFeedbackLabelsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1177,7 +2762,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetEncryptionSpec._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListFeedbackLabels._get_unset_required_fields( query_params ) ) @@ -1185,7 +2770,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetIssue: + class _BaseListIssueModels: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1204,14 +2789,14 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/issueModels/*/issues/*}", + "uri": "/v1/{parent=projects/*/locations/*}/issueModels", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetIssueRequest.pb(request) + pb_request = contact_center_insights.ListIssueModelsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1224,7 +2809,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetIssue._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_unset_required_fields( query_params ) ) @@ -1232,7 +2817,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetIssueModel: + class _BaseListIssues: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1251,14 +2836,14 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/issueModels/*}", + "uri": "/v1/{parent=projects/*/locations/*/issueModels/*}/issues", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetIssueModelRequest.pb(request) + pb_request = contact_center_insights.ListIssuesRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1271,7 +2856,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListIssues._get_unset_required_fields( query_params ) ) @@ -1279,7 +2864,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetPhraseMatcher: + class _BaseListPhraseMatchers: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1298,14 +2883,14 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/phraseMatchers/*}", + "uri": "/v1/{parent=projects/*/locations/*}/phraseMatchers", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetPhraseMatcherRequest.pb(request) + pb_request = contact_center_insights.ListPhraseMatchersRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1318,7 +2903,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetPhraseMatcher._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_unset_required_fields( query_params ) ) @@ -1326,7 +2911,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetSettings: + class _BaseListQaQuestions: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1345,14 +2930,14 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/settings}", + "uri": "/v1/{parent=projects/*/locations/*/qaScorecards/*/revisions/*}/qaQuestions", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetSettingsRequest.pb(request) + pb_request = contact_center_insights.ListQaQuestionsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1365,7 +2950,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetSettings._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListQaQuestions._get_unset_required_fields( query_params ) ) @@ -1373,7 +2958,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetView: + class _BaseListQaScorecardRevisions: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1392,14 +2977,16 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1/{name=projects/*/locations/*/views/*}", + "uri": "/v1/{parent=projects/*/locations/*/qaScorecards/*}/revisions", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.GetViewRequest.pb(request) + pb_request = contact_center_insights.ListQaScorecardRevisionsRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1412,7 +2999,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseGetView._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListQaScorecardRevisions._get_unset_required_fields( query_params ) ) @@ -1420,7 +3007,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseImportIssueModel: + class _BaseListQaScorecards: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1438,28 +3025,18 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/issueModels:import", - "body": "*", + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/qaScorecards", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ImportIssueModelRequest.pb(request) + pb_request = contact_center_insights.ListQaScorecardsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1469,7 +3046,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseImportIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListQaScorecards._get_unset_required_fields( query_params ) ) @@ -1477,7 +3054,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseIngestConversations: + class _BaseListViews: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1495,28 +3072,18 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/conversations:ingest", - "body": "*", + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/views", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.IngestConversationsRequest.pb(request) + pb_request = contact_center_insights.ListViewsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1526,7 +3093,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseIngestConversations._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseListViews._get_unset_required_fields( query_params ) ) @@ -1534,7 +3101,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseInitializeEncryptionSpec: + class _BaseQueryMetrics: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1553,7 +3120,7 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1/{encryption_spec.name=projects/*/locations/*/encryptionSpec}:initialize", + "uri": "/v1/{location=projects/*/locations/*}:queryMetrics", "body": "*", }, ] @@ -1561,9 +3128,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.InitializeEncryptionSpecRequest.pb( - request - ) + pb_request = contact_center_insights.QueryMetricsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1585,7 +3150,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseInitializeEncryptionSpec._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseQueryMetrics._get_unset_required_fields( query_params ) ) @@ -1593,7 +3158,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListAnalyses: + class _BaseTuneQaScorecardRevision: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1611,18 +3176,30 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*/conversations/*}/analyses", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/qaScorecards/*/revisions/*}:tuneQaScorecardRevision", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ListAnalysesRequest.pb(request) + pb_request = contact_center_insights.TuneQaScorecardRevisionRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1632,7 +3209,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseListAnalyses._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseTuneQaScorecardRevision._get_unset_required_fields( query_params ) ) @@ -1640,7 +3217,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListConversations: + class _BaseUndeployIssueModel: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1658,18 +3235,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/conversations", + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/issueModels/*}:undeploy", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ListConversationsRequest.pb(request) + pb_request = contact_center_insights.UndeployIssueModelRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1679,7 +3266,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseListConversations._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_unset_required_fields( query_params ) ) @@ -1687,7 +3274,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListIssueModels: + class _BaseUndeployQaScorecardRevision: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1705,18 +3292,30 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/issueModels", + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*}:undeploy", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ListIssueModelsRequest.pb(request) + pb_request = contact_center_insights.UndeployQaScorecardRevisionRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1726,7 +3325,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseListIssueModels._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUndeployQaScorecardRevision._get_unset_required_fields( query_params ) ) @@ -1734,7 +3333,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListIssues: + class _BaseUpdateAnalysisRule: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1752,18 +3351,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*/issueModels/*}/issues", + "method": "patch", + "uri": "/v1/{analysis_rule.name=projects/*/locations/*/analysisRules/*}", + "body": "analysis_rule", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ListIssuesRequest.pb(request) + pb_request = contact_center_insights.UpdateAnalysisRuleRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1773,7 +3382,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseListIssues._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdateAnalysisRule._get_unset_required_fields( query_params ) ) @@ -1781,7 +3390,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListPhraseMatchers: + class _BaseUpdateConversation: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1799,18 +3408,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/phraseMatchers", + "method": "patch", + "uri": "/v1/{conversation.name=projects/*/locations/*/conversations/*}", + "body": "conversation", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ListPhraseMatchersRequest.pb(request) + pb_request = contact_center_insights.UpdateConversationRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1820,7 +3439,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseListPhraseMatchers._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_unset_required_fields( query_params ) ) @@ -1828,11 +3447,13 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListViews: + class _BaseUpdateFeedbackLabel: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1846,18 +3467,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/views", + "method": "patch", + "uri": "/v1/{feedback_label.name=projects/*/locations/*/conversations/*/feedbackLabels/*}", + "body": "feedback_label", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.ListViewsRequest.pb(request) + pb_request = contact_center_insights.UpdateFeedbackLabelRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1867,7 +3498,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseListViews._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdateFeedbackLabel._get_unset_required_fields( query_params ) ) @@ -1875,7 +3506,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseUndeployIssueModel: + class _BaseUpdateIssue: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1893,16 +3524,16 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{name=projects/*/locations/*/issueModels/*}:undeploy", - "body": "*", + "method": "patch", + "uri": "/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}", + "body": "issue", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.UndeployIssueModelRequest.pb(request) + pb_request = contact_center_insights.UpdateIssueRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1924,7 +3555,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseUndeployIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_unset_required_fields( query_params ) ) @@ -1932,7 +3563,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseUpdateConversation: + class _BaseUpdateIssueModel: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1951,15 +3582,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "patch", - "uri": "/v1/{conversation.name=projects/*/locations/*/conversations/*}", - "body": "conversation", + "uri": "/v1/{issue_model.name=projects/*/locations/*/issueModels/*}", + "body": "issue_model", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.UpdateConversationRequest.pb(request) + pb_request = contact_center_insights.UpdateIssueModelRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -1981,7 +3612,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseUpdateConversation._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_unset_required_fields( query_params ) ) @@ -1989,7 +3620,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseUpdateIssue: + class _BaseUpdatePhraseMatcher: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -2008,15 +3639,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "patch", - "uri": "/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}", - "body": "issue", + "uri": "/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}", + "body": "phrase_matcher", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.UpdateIssueRequest.pb(request) + pb_request = contact_center_insights.UpdatePhraseMatcherRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -2038,7 +3669,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseUpdateIssue._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_unset_required_fields( query_params ) ) @@ -2046,11 +3677,13 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseUpdateIssueModel: + class _BaseUpdateQaQuestion: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): @@ -2065,15 +3698,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "patch", - "uri": "/v1/{issue_model.name=projects/*/locations/*/issueModels/*}", - "body": "issue_model", + "uri": "/v1/{qa_question.name=projects/*/locations/*/qaScorecards/*/revisions/*/qaQuestions/*}", + "body": "qa_question", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.UpdateIssueModelRequest.pb(request) + pb_request = contact_center_insights.UpdateQaQuestionRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -2095,7 +3728,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseUpdateIssueModel._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdateQaQuestion._get_unset_required_fields( query_params ) ) @@ -2103,11 +3736,13 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseUpdatePhraseMatcher: + class _BaseUpdateQaScorecard: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): @@ -2122,15 +3757,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "patch", - "uri": "/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}", - "body": "phrase_matcher", + "uri": "/v1/{qa_scorecard.name=projects/*/locations/*/qaScorecards/*}", + "body": "qa_scorecard", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = contact_center_insights.UpdatePhraseMatcherRequest.pb(request) + pb_request = contact_center_insights.UpdateQaScorecardRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -2152,7 +3787,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseContactCenterInsightsRestTransport._BaseUpdatePhraseMatcher._get_unset_required_fields( + _BaseContactCenterInsightsRestTransport._BaseUpdateQaScorecard._get_unset_required_fields( query_params ) ) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py index 30e7ff857b46..d4096cc0eb7f 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py @@ -20,6 +20,12 @@ BulkDeleteConversationsMetadata, BulkDeleteConversationsRequest, BulkDeleteConversationsResponse, + BulkDownloadFeedbackLabelsMetadata, + BulkDownloadFeedbackLabelsRequest, + BulkDownloadFeedbackLabelsResponse, + BulkUploadFeedbackLabelsMetadata, + BulkUploadFeedbackLabelsRequest, + BulkUploadFeedbackLabelsResponse, CalculateIssueModelStatsRequest, CalculateIssueModelStatsResponse, CalculateStatsRequest, @@ -27,21 +33,33 @@ ConversationView, CreateAnalysisOperationMetadata, CreateAnalysisRequest, + CreateAnalysisRuleRequest, CreateConversationRequest, + CreateFeedbackLabelRequest, CreateIssueModelMetadata, CreateIssueModelRequest, CreatePhraseMatcherRequest, + CreateQaQuestionRequest, + CreateQaScorecardRequest, + CreateQaScorecardRevisionRequest, CreateViewRequest, DeleteAnalysisRequest, + DeleteAnalysisRuleRequest, DeleteConversationRequest, + DeleteFeedbackLabelRequest, DeleteIssueModelMetadata, DeleteIssueModelRequest, DeleteIssueRequest, DeletePhraseMatcherRequest, + DeleteQaQuestionRequest, + DeleteQaScorecardRequest, + DeleteQaScorecardRevisionRequest, DeleteViewRequest, DeployIssueModelMetadata, DeployIssueModelRequest, DeployIssueModelResponse, + DeployQaScorecardRevisionRequest, + Dimension, ExportInsightsDataMetadata, ExportInsightsDataRequest, ExportInsightsDataResponse, @@ -49,11 +67,16 @@ ExportIssueModelRequest, ExportIssueModelResponse, GetAnalysisRequest, + GetAnalysisRuleRequest, GetConversationRequest, GetEncryptionSpecRequest, + GetFeedbackLabelRequest, GetIssueModelRequest, GetIssueRequest, GetPhraseMatcherRequest, + GetQaQuestionRequest, + GetQaScorecardRequest, + GetQaScorecardRevisionRequest, GetSettingsRequest, GetViewRequest, ImportIssueModelMetadata, @@ -65,25 +88,48 @@ InitializeEncryptionSpecMetadata, InitializeEncryptionSpecRequest, InitializeEncryptionSpecResponse, + ListAllFeedbackLabelsRequest, + ListAllFeedbackLabelsResponse, ListAnalysesRequest, ListAnalysesResponse, + ListAnalysisRulesRequest, + ListAnalysisRulesResponse, ListConversationsRequest, ListConversationsResponse, + ListFeedbackLabelsRequest, + ListFeedbackLabelsResponse, ListIssueModelsRequest, ListIssueModelsResponse, ListIssuesRequest, ListIssuesResponse, ListPhraseMatchersRequest, ListPhraseMatchersResponse, + ListQaQuestionsRequest, + ListQaQuestionsResponse, + ListQaScorecardRevisionsRequest, + ListQaScorecardRevisionsResponse, + ListQaScorecardsRequest, + ListQaScorecardsResponse, ListViewsRequest, ListViewsResponse, + QueryMetricsMetadata, + QueryMetricsRequest, + QueryMetricsResponse, + TuneQaScorecardRevisionMetadata, + TuneQaScorecardRevisionRequest, + TuneQaScorecardRevisionResponse, UndeployIssueModelMetadata, UndeployIssueModelRequest, UndeployIssueModelResponse, + UndeployQaScorecardRevisionRequest, + UpdateAnalysisRuleRequest, UpdateConversationRequest, + UpdateFeedbackLabelRequest, UpdateIssueModelRequest, UpdateIssueRequest, UpdatePhraseMatcherRequest, + UpdateQaQuestionRequest, + UpdateQaScorecardRequest, UpdateSettingsRequest, UpdateViewRequest, UploadConversationMetadata, @@ -92,6 +138,7 @@ from .resources import ( Analysis, AnalysisResult, + AnalysisRule, AnnotationBoundary, AnnotatorSelector, AnswerFeedback, @@ -103,6 +150,7 @@ ConversationLevelSilence, ConversationParticipant, ConversationSummarizationSuggestionData, + DatasetValidationWarning, DialogflowIntent, DialogflowInteractionData, DialogflowSource, @@ -111,6 +159,7 @@ EntityMentionData, ExactMatchConfig, FaqAnswerData, + FeedbackLabel, GcsSource, HoldData, Intent, @@ -127,6 +176,11 @@ PhraseMatchRule, PhraseMatchRuleConfig, PhraseMatchRuleGroup, + QaAnswer, + QaQuestion, + QaScorecard, + QaScorecardResult, + QaScorecardRevision, RedactionConfig, RuntimeAnnotation, SentimentData, @@ -145,27 +199,45 @@ "BulkDeleteConversationsMetadata", "BulkDeleteConversationsRequest", "BulkDeleteConversationsResponse", + "BulkDownloadFeedbackLabelsMetadata", + "BulkDownloadFeedbackLabelsRequest", + "BulkDownloadFeedbackLabelsResponse", + "BulkUploadFeedbackLabelsMetadata", + "BulkUploadFeedbackLabelsRequest", + "BulkUploadFeedbackLabelsResponse", "CalculateIssueModelStatsRequest", "CalculateIssueModelStatsResponse", "CalculateStatsRequest", "CalculateStatsResponse", "CreateAnalysisOperationMetadata", "CreateAnalysisRequest", + "CreateAnalysisRuleRequest", "CreateConversationRequest", + "CreateFeedbackLabelRequest", "CreateIssueModelMetadata", "CreateIssueModelRequest", "CreatePhraseMatcherRequest", + "CreateQaQuestionRequest", + "CreateQaScorecardRequest", + "CreateQaScorecardRevisionRequest", "CreateViewRequest", "DeleteAnalysisRequest", + "DeleteAnalysisRuleRequest", "DeleteConversationRequest", + "DeleteFeedbackLabelRequest", "DeleteIssueModelMetadata", "DeleteIssueModelRequest", "DeleteIssueRequest", "DeletePhraseMatcherRequest", + "DeleteQaQuestionRequest", + "DeleteQaScorecardRequest", + "DeleteQaScorecardRevisionRequest", "DeleteViewRequest", "DeployIssueModelMetadata", "DeployIssueModelRequest", "DeployIssueModelResponse", + "DeployQaScorecardRevisionRequest", + "Dimension", "ExportInsightsDataMetadata", "ExportInsightsDataRequest", "ExportInsightsDataResponse", @@ -173,11 +245,16 @@ "ExportIssueModelRequest", "ExportIssueModelResponse", "GetAnalysisRequest", + "GetAnalysisRuleRequest", "GetConversationRequest", "GetEncryptionSpecRequest", + "GetFeedbackLabelRequest", "GetIssueModelRequest", "GetIssueRequest", "GetPhraseMatcherRequest", + "GetQaQuestionRequest", + "GetQaScorecardRequest", + "GetQaScorecardRevisionRequest", "GetSettingsRequest", "GetViewRequest", "ImportIssueModelMetadata", @@ -189,25 +266,48 @@ "InitializeEncryptionSpecMetadata", "InitializeEncryptionSpecRequest", "InitializeEncryptionSpecResponse", + "ListAllFeedbackLabelsRequest", + "ListAllFeedbackLabelsResponse", "ListAnalysesRequest", "ListAnalysesResponse", + "ListAnalysisRulesRequest", + "ListAnalysisRulesResponse", "ListConversationsRequest", "ListConversationsResponse", + "ListFeedbackLabelsRequest", + "ListFeedbackLabelsResponse", "ListIssueModelsRequest", "ListIssueModelsResponse", "ListIssuesRequest", "ListIssuesResponse", "ListPhraseMatchersRequest", "ListPhraseMatchersResponse", + "ListQaQuestionsRequest", + "ListQaQuestionsResponse", + "ListQaScorecardRevisionsRequest", + "ListQaScorecardRevisionsResponse", + "ListQaScorecardsRequest", + "ListQaScorecardsResponse", "ListViewsRequest", "ListViewsResponse", + "QueryMetricsMetadata", + "QueryMetricsRequest", + "QueryMetricsResponse", + "TuneQaScorecardRevisionMetadata", + "TuneQaScorecardRevisionRequest", + "TuneQaScorecardRevisionResponse", "UndeployIssueModelMetadata", "UndeployIssueModelRequest", "UndeployIssueModelResponse", + "UndeployQaScorecardRevisionRequest", + "UpdateAnalysisRuleRequest", "UpdateConversationRequest", + "UpdateFeedbackLabelRequest", "UpdateIssueModelRequest", "UpdateIssueRequest", "UpdatePhraseMatcherRequest", + "UpdateQaQuestionRequest", + "UpdateQaScorecardRequest", "UpdateSettingsRequest", "UpdateViewRequest", "UploadConversationMetadata", @@ -215,6 +315,7 @@ "ConversationView", "Analysis", "AnalysisResult", + "AnalysisRule", "AnnotationBoundary", "AnnotatorSelector", "AnswerFeedback", @@ -234,6 +335,7 @@ "EntityMentionData", "ExactMatchConfig", "FaqAnswerData", + "FeedbackLabel", "GcsSource", "HoldData", "Intent", @@ -250,6 +352,11 @@ "PhraseMatchRule", "PhraseMatchRuleConfig", "PhraseMatchRuleGroup", + "QaAnswer", + "QaQuestion", + "QaScorecard", + "QaScorecardResult", + "QaScorecardRevision", "RedactionConfig", "RuntimeAnnotation", "SentimentData", @@ -259,4 +366,5 @@ "SmartReplyData", "SpeechConfig", "View", + "DatasetValidationWarning", ) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py index 1229fb10453f..f1c1376e7f22 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py @@ -21,6 +21,7 @@ from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore +from google.type import interval_pb2 # type: ignore import proto # type: ignore from google.cloud.contact_center_insights_v1.types import resources @@ -92,6 +93,12 @@ "UpdatePhraseMatcherRequest", "GetSettingsRequest", "UpdateSettingsRequest", + "CreateAnalysisRuleRequest", + "GetAnalysisRuleRequest", + "UpdateAnalysisRuleRequest", + "DeleteAnalysisRuleRequest", + "ListAnalysisRulesRequest", + "ListAnalysisRulesResponse", "GetEncryptionSpecRequest", "InitializeEncryptionSpecRequest", "InitializeEncryptionSpecResponse", @@ -102,6 +109,46 @@ "ListViewsResponse", "UpdateViewRequest", "DeleteViewRequest", + "Dimension", + "QueryMetricsRequest", + "QueryMetricsResponse", + "QueryMetricsMetadata", + "CreateQaQuestionRequest", + "GetQaQuestionRequest", + "ListQaQuestionsRequest", + "ListQaQuestionsResponse", + "UpdateQaQuestionRequest", + "DeleteQaQuestionRequest", + "CreateQaScorecardRequest", + "GetQaScorecardRequest", + "UpdateQaScorecardRequest", + "DeleteQaScorecardRequest", + "CreateQaScorecardRevisionRequest", + "GetQaScorecardRevisionRequest", + "TuneQaScorecardRevisionRequest", + "TuneQaScorecardRevisionResponse", + "TuneQaScorecardRevisionMetadata", + "DeployQaScorecardRevisionRequest", + "UndeployQaScorecardRevisionRequest", + "DeleteQaScorecardRevisionRequest", + "ListQaScorecardsRequest", + "ListQaScorecardsResponse", + "ListQaScorecardRevisionsRequest", + "ListQaScorecardRevisionsResponse", + "CreateFeedbackLabelRequest", + "ListFeedbackLabelsRequest", + "ListFeedbackLabelsResponse", + "GetFeedbackLabelRequest", + "UpdateFeedbackLabelRequest", + "DeleteFeedbackLabelRequest", + "ListAllFeedbackLabelsRequest", + "ListAllFeedbackLabelsResponse", + "BulkUploadFeedbackLabelsRequest", + "BulkUploadFeedbackLabelsResponse", + "BulkUploadFeedbackLabelsMetadata", + "BulkDownloadFeedbackLabelsRequest", + "BulkDownloadFeedbackLabelsResponse", + "BulkDownloadFeedbackLabelsMetadata", }, ) @@ -701,7 +748,7 @@ class GcsSource(proto.Message): Optional. Custom keys to extract as conversation labels from metadata files in ``metadata_bucket_uri``. Keys not included in this field will be ignored. Note that there is a limit of - 20 labels per conversation. + 100 labels per conversation. """ class BucketObjectType(proto.Enum): @@ -2099,6 +2146,147 @@ class UpdateSettingsRequest(proto.Message): ) +class CreateAnalysisRuleRequest(proto.Message): + r"""The request to create a analysis rule. analysis_rule_id will be + generated by the server. + + Attributes: + parent (str): + Required. The parent resource of the analysis rule. + Required. The location to create a analysis rule for. + Format: ``projects//locations/`` or + ``projects//locations/`` + analysis_rule (google.cloud.contact_center_insights_v1.types.AnalysisRule): + Required. The analysis rule resource to + create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + analysis_rule: resources.AnalysisRule = proto.Field( + proto.MESSAGE, + number=2, + message=resources.AnalysisRule, + ) + + +class GetAnalysisRuleRequest(proto.Message): + r"""The request for getting a analysis rule. + + Attributes: + name (str): + Required. The name of the AnalysisRule to + get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateAnalysisRuleRequest(proto.Message): + r"""The request to update a analysis rule. + + Attributes: + analysis_rule (google.cloud.contact_center_insights_v1.types.AnalysisRule): + Required. The new analysis rule. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. The list of fields to be updated. If the + update_mask is not provided, the update will be applied to + all fields. + """ + + analysis_rule: resources.AnalysisRule = proto.Field( + proto.MESSAGE, + number=1, + message=resources.AnalysisRule, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteAnalysisRuleRequest(proto.Message): + r"""The request to delete a analysis rule. + + Attributes: + name (str): + Required. The name of the analysis rule to + delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListAnalysisRulesRequest(proto.Message): + r"""The request to list analysis rules. + + Attributes: + parent (str): + Required. The parent resource of the analysis + rules. + page_size (int): + Optional. The maximum number of analysis rule to return in + the response. If this value is zero, the service will select + a default size. A call may return fewer objects than + requested. A non-empty ``next_page_token`` in the response + indicates that more data is available. + page_token (str): + Optional. The value returned by the last + ``ListAnalysisRulesResponse``; indicates that this is a + continuation of a prior ``ListAnalysisRules`` call and the + system should return the next page of data. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListAnalysisRulesResponse(proto.Message): + r"""The response of listing views. + + Attributes: + analysis_rules (MutableSequence[google.cloud.contact_center_insights_v1.types.AnalysisRule]): + The analysis_rule that match the request. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + analysis_rules: MutableSequence[resources.AnalysisRule] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.AnalysisRule, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + class GetEncryptionSpecRequest(proto.Message): r"""The request to get location-level encryption specification. @@ -2123,8 +2311,9 @@ class InitializeEncryptionSpecRequest(proto.Message): Required. The encryption spec used for CMEK encryption. It is required that the kms key is in the same region as the endpoint. The same key will be used for all provisioned - resources, if encryption is available. If the kms_key_name - is left empty, no encryption will be enforced. + resources, if encryption is available. If the + ``kms_key_name`` field is left empty, no encryption will be + enforced. """ encryption_spec: resources.EncryptionSpec = proto.Field( @@ -2156,7 +2345,7 @@ class InitializeEncryptionSpecMetadata(proto.Message): Output only. The original request for initialization. partial_errors (MutableSequence[google.rpc.status_pb2.Status]): - Partial errors during initialising operation + Partial errors during initializing operation that might cause the operation output to be incomplete. """ @@ -2317,4 +2506,1917 @@ class DeleteViewRequest(proto.Message): ) +class Dimension(proto.Message): + r"""A dimension determines the grouping key for the query. In SQL + terms, these would be part of both the "SELECT" and "GROUP BY" + clauses. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + issue_dimension_metadata (google.cloud.contact_center_insights_v1.types.Dimension.IssueDimensionMetadata): + Output only. Metadata about the issue + dimension. + + This field is a member of `oneof`_ ``dimension_metadata``. + agent_dimension_metadata (google.cloud.contact_center_insights_v1.types.Dimension.AgentDimensionMetadata): + Output only. Metadata about the agent + dimension. + + This field is a member of `oneof`_ ``dimension_metadata``. + qa_question_dimension_metadata (google.cloud.contact_center_insights_v1.types.Dimension.QaQuestionDimensionMetadata): + Output only. Metadata about the QA question + dimension. + + This field is a member of `oneof`_ ``dimension_metadata``. + qa_question_answer_dimension_metadata (google.cloud.contact_center_insights_v1.types.Dimension.QaQuestionAnswerDimensionMetadata): + Output only. Metadata about the QA + question-answer dimension. + + This field is a member of `oneof`_ ``dimension_metadata``. + dimension_key (google.cloud.contact_center_insights_v1.types.Dimension.DimensionKey): + The key of the dimension. + """ + + class DimensionKey(proto.Enum): + r"""The key of the dimension. + + Values: + DIMENSION_KEY_UNSPECIFIED (0): + The key of the dimension is unspecified. + ISSUE (1): + The dimension is keyed by issues. + AGENT (2): + The dimension is keyed by agents. + AGENT_TEAM (3): + The dimension is keyed by agent teams. + QA_QUESTION_ID (4): + The dimension is keyed by QaQuestionIds. + Note that: We only group by the QuestionId and + not the revision-id of the scorecard this + question is a part of. This allows for showing + stats for the same question across different + scorecard revisions. + QA_QUESTION_ANSWER_VALUE (5): + The dimension is keyed by + QaQuestionIds-Answer value pairs. Note that: We + only group by the QuestionId and not the + revision-id of the scorecard this question is a + part of. This allows for showing distribution of + answers per question across different scorecard + revisions. + CONVERSATION_PROFILE_ID (6): + The dimension is keyed by the conversation + profile ID. + """ + DIMENSION_KEY_UNSPECIFIED = 0 + ISSUE = 1 + AGENT = 2 + AGENT_TEAM = 3 + QA_QUESTION_ID = 4 + QA_QUESTION_ANSWER_VALUE = 5 + CONVERSATION_PROFILE_ID = 6 + + class IssueDimensionMetadata(proto.Message): + r"""Metadata about the issue dimension. + + Attributes: + issue_id (str): + The issue ID. + issue_display_name (str): + The issue display name. + issue_model_id (str): + The parent issue model ID. + """ + + issue_id: str = proto.Field( + proto.STRING, + number=1, + ) + issue_display_name: str = proto.Field( + proto.STRING, + number=2, + ) + issue_model_id: str = proto.Field( + proto.STRING, + number=3, + ) + + class AgentDimensionMetadata(proto.Message): + r"""Metadata about the agent dimension. + + Attributes: + agent_id (str): + Optional. A user-specified string + representing the agent. + agent_display_name (str): + Optional. The agent's name + agent_team (str): + Optional. A user-specified string + representing the agent's team. + """ + + agent_id: str = proto.Field( + proto.STRING, + number=1, + ) + agent_display_name: str = proto.Field( + proto.STRING, + number=2, + ) + agent_team: str = proto.Field( + proto.STRING, + number=3, + ) + + class QaQuestionDimensionMetadata(proto.Message): + r"""Metadata about the QA question dimension. + + Attributes: + qa_scorecard_id (str): + Optional. The QA scorecard ID. + qa_question_id (str): + Optional. The QA question ID. + question_body (str): + Optional. The full body of the question. + """ + + qa_scorecard_id: str = proto.Field( + proto.STRING, + number=1, + ) + qa_question_id: str = proto.Field( + proto.STRING, + number=2, + ) + question_body: str = proto.Field( + proto.STRING, + number=3, + ) + + class QaQuestionAnswerDimensionMetadata(proto.Message): + r"""Metadata about the QA question-answer dimension. + This is useful for showing the answer distribution for questions + for a given scorecard. + + Attributes: + qa_scorecard_id (str): + Optional. The QA scorecard ID. + qa_question_id (str): + Optional. The QA question ID. + question_body (str): + Optional. The full body of the question. + answer_value (str): + Optional. The full body of the question. + """ + + qa_scorecard_id: str = proto.Field( + proto.STRING, + number=1, + ) + qa_question_id: str = proto.Field( + proto.STRING, + number=2, + ) + question_body: str = proto.Field( + proto.STRING, + number=3, + ) + answer_value: str = proto.Field( + proto.STRING, + number=4, + ) + + issue_dimension_metadata: IssueDimensionMetadata = proto.Field( + proto.MESSAGE, + number=2, + oneof="dimension_metadata", + message=IssueDimensionMetadata, + ) + agent_dimension_metadata: AgentDimensionMetadata = proto.Field( + proto.MESSAGE, + number=3, + oneof="dimension_metadata", + message=AgentDimensionMetadata, + ) + qa_question_dimension_metadata: QaQuestionDimensionMetadata = proto.Field( + proto.MESSAGE, + number=4, + oneof="dimension_metadata", + message=QaQuestionDimensionMetadata, + ) + qa_question_answer_dimension_metadata: QaQuestionAnswerDimensionMetadata = ( + proto.Field( + proto.MESSAGE, + number=5, + oneof="dimension_metadata", + message=QaQuestionAnswerDimensionMetadata, + ) + ) + dimension_key: DimensionKey = proto.Field( + proto.ENUM, + number=1, + enum=DimensionKey, + ) + + +class QueryMetricsRequest(proto.Message): + r"""The request for querying metrics. + + Attributes: + location (str): + Required. The location of the data. + "projects/{project}/locations/{location}". + filter (str): + Required. Filter to select a subset of conversations to + compute the metrics. Must specify a window of the + conversation create time to compute the metrics. The + returned metrics will be from the range [DATE(starting + create time), DATE(ending create time)). + time_granularity (google.cloud.contact_center_insights_v1.types.QueryMetricsRequest.TimeGranularity): + The time granularity of each data point in + the time series. Defaults to NONE if this field + is unspecified. + dimensions (MutableSequence[google.cloud.contact_center_insights_v1.types.Dimension]): + The dimensions that determine the grouping + key for the query. Defaults to no dimension if + this field is unspecified. If a dimension is + specified, its key must also be specified. Each + dimension's key must be unique. + + If a time granularity is also specified, metric + values in the dimension will be bucketed by this + granularity. + + Up to one dimension is supported for now. + measure_mask (google.protobuf.field_mask_pb2.FieldMask): + Measures to return. Defaults to all measures if this field + is unspecified. A valid mask should traverse from the + ``measure`` field from the response. For example, a path + from a measure mask to get the conversation count is + "conversation_measure.count". + """ + + class TimeGranularity(proto.Enum): + r"""A time granularity divides the time line into discrete time + periods. This is useful for defining buckets over which + filtering and aggregation should be performed. + + Values: + TIME_GRANULARITY_UNSPECIFIED (0): + The time granularity is unspecified and will + default to NONE. + NONE (1): + No time granularity. The response won't + contain a time series. This is the default value + if no time granularity is specified. + DAILY (2): + Data points in the time series will aggregate at a daily + granularity. 1 day means [midnight to midnight). + HOURLY (3): + Data points in the time series will aggregate at a daily + granularity. 1 HOUR means [01:00 to 02:00). + PER_MINUTE (4): + Data points in the time series will aggregate at a daily + granularity. PER_MINUTE means [01:00 to 01:01). + PER_5_MINUTES (5): + Data points in the time series will aggregate at a 1 minute + granularity. PER_5_MINUTES means [01:00 to 01:05). + MONTHLY (6): + Data points in the time series will aggregate at a monthly + granularity. 1 MONTH means [01st of the month to 1st of the + next month). + """ + TIME_GRANULARITY_UNSPECIFIED = 0 + NONE = 1 + DAILY = 2 + HOURLY = 3 + PER_MINUTE = 4 + PER_5_MINUTES = 5 + MONTHLY = 6 + + location: str = proto.Field( + proto.STRING, + number=1, + ) + filter: str = proto.Field( + proto.STRING, + number=2, + ) + time_granularity: TimeGranularity = proto.Field( + proto.ENUM, + number=3, + enum=TimeGranularity, + ) + dimensions: MutableSequence["Dimension"] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message="Dimension", + ) + measure_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=5, + message=field_mask_pb2.FieldMask, + ) + + +class QueryMetricsResponse(proto.Message): + r"""The response for querying metrics. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + location (str): + Required. The location of the data. + "projects/{project}/locations/{location}". + update_time (google.protobuf.timestamp_pb2.Timestamp): + The metrics last update time. + slices (MutableSequence[google.cloud.contact_center_insights_v1.types.QueryMetricsResponse.Slice]): + A slice contains a total and (if the request + specified a time granularity) a time series of + metric values. Each slice contains a unique + combination of the cardinality of dimensions + from the request. + macro_average_slice (google.cloud.contact_center_insights_v1.types.QueryMetricsResponse.Slice): + The macro average slice contains aggregated averages across + the selected dimension. i.e. if group_by agent is specified + this field will contain the average across all agents. This + field is only populated if the request specifies a + Dimension. + + This field is a member of `oneof`_ ``_macro_average_slice``. + """ + + class Slice(proto.Message): + r"""A slice contains a total and (if the request specified a time + granularity) a time series of metric values. Each slice contains a + unique combination of the cardinality of dimensions from the + request. + + For example, if the request specifies a single ISSUE dimension and + it has a cardinality of 2 (i.e. the data used to compute the metrics + has 2 issues in total), the response will have 2 slices: + + - Slice 1 -> dimensions=[Issue 1] + - Slice 2 -> dimensions=[Issue 2] + + Attributes: + dimensions (MutableSequence[google.cloud.contact_center_insights_v1.types.Dimension]): + A unique combination of dimensions that this + slice represents. + total (google.cloud.contact_center_insights_v1.types.QueryMetricsResponse.Slice.DataPoint): + The total metric value. The interval of this data point is + [starting create time, ending create time) from the request. + time_series (google.cloud.contact_center_insights_v1.types.QueryMetricsResponse.Slice.TimeSeries): + A time series of metric values. This is only + populated if the request specifies a time + granularity other than NONE. + """ + + class DataPoint(proto.Message): + r"""A data point contains the metric values mapped to an + interval. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + conversation_measure (google.cloud.contact_center_insights_v1.types.QueryMetricsResponse.Slice.DataPoint.ConversationMeasure): + The measure related to conversations. + + This field is a member of `oneof`_ ``measure``. + interval (google.type.interval_pb2.Interval): + The interval that this data point represents. + + - If this is the total data point, the interval is + [starting create time, ending create time) from the + request. + - If this a data point from the time series, the interval + is [time, time + time granularity from the request). + """ + + class ConversationMeasure(proto.Message): + r"""The measure related to conversations. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + conversation_count (int): + The conversation count. + + This field is a member of `oneof`_ ``_conversation_count``. + average_silence_percentage (float): + The average silence percentage. + + This field is a member of `oneof`_ ``_average_silence_percentage``. + average_duration (google.protobuf.duration_pb2.Duration): + The average duration. + + This field is a member of `oneof`_ ``_average_duration``. + average_turn_count (float): + The average turn count. + + This field is a member of `oneof`_ ``_average_turn_count``. + average_agent_sentiment_score (float): + The average agent's sentiment score. + + This field is a member of `oneof`_ ``_average_agent_sentiment_score``. + average_client_sentiment_score (float): + The average client's sentiment score. + + This field is a member of `oneof`_ ``_average_client_sentiment_score``. + average_customer_satisfaction_rating (float): + The average customer satisfaction rating. + + This field is a member of `oneof`_ ``_average_customer_satisfaction_rating``. + average_qa_normalized_score (float): + Average QA normalized score. + Will exclude 0's in average calculation. + + This field is a member of `oneof`_ ``_average_qa_normalized_score``. + qa_tag_scores (MutableSequence[google.cloud.contact_center_insights_v1.types.QueryMetricsResponse.Slice.DataPoint.ConversationMeasure.QaTagScore]): + Average QA normalized score for all the tags. + average_qa_question_normalized_score (float): + Average QA normalized score averaged for questions averaged + across all revisions of the parent scorecard. Will be only + populated if the request specifies a dimension of + QA_QUESTION_ID. + + This field is a member of `oneof`_ ``_average_qa_question_normalized_score``. + """ + + class QaTagScore(proto.Message): + r"""Average QA normalized score for the tag. + + Attributes: + tag (str): + Tag name. + average_tag_normalized_score (float): + Average tag normalized score per tag. + """ + + tag: str = proto.Field( + proto.STRING, + number=1, + ) + average_tag_normalized_score: float = proto.Field( + proto.DOUBLE, + number=2, + ) + + conversation_count: int = proto.Field( + proto.INT32, + number=1, + optional=True, + ) + average_silence_percentage: float = proto.Field( + proto.FLOAT, + number=2, + optional=True, + ) + average_duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=3, + optional=True, + message=duration_pb2.Duration, + ) + average_turn_count: float = proto.Field( + proto.FLOAT, + number=4, + optional=True, + ) + average_agent_sentiment_score: float = proto.Field( + proto.FLOAT, + number=5, + optional=True, + ) + average_client_sentiment_score: float = proto.Field( + proto.FLOAT, + number=6, + optional=True, + ) + average_customer_satisfaction_rating: float = proto.Field( + proto.DOUBLE, + number=8, + optional=True, + ) + average_qa_normalized_score: float = proto.Field( + proto.DOUBLE, + number=7, + optional=True, + ) + qa_tag_scores: MutableSequence[ + "QueryMetricsResponse.Slice.DataPoint.ConversationMeasure.QaTagScore" + ] = proto.RepeatedField( + proto.MESSAGE, + number=9, + message="QueryMetricsResponse.Slice.DataPoint.ConversationMeasure.QaTagScore", + ) + average_qa_question_normalized_score: float = proto.Field( + proto.DOUBLE, + number=10, + optional=True, + ) + + conversation_measure: "QueryMetricsResponse.Slice.DataPoint.ConversationMeasure" = proto.Field( + proto.MESSAGE, + number=2, + oneof="measure", + message="QueryMetricsResponse.Slice.DataPoint.ConversationMeasure", + ) + interval: interval_pb2.Interval = proto.Field( + proto.MESSAGE, + number=1, + message=interval_pb2.Interval, + ) + + class TimeSeries(proto.Message): + r"""A time series of metric values. + + Attributes: + data_points (MutableSequence[google.cloud.contact_center_insights_v1.types.QueryMetricsResponse.Slice.DataPoint]): + The data points that make up the time series + . + """ + + data_points: MutableSequence[ + "QueryMetricsResponse.Slice.DataPoint" + ] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message="QueryMetricsResponse.Slice.DataPoint", + ) + + dimensions: MutableSequence["Dimension"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Dimension", + ) + total: "QueryMetricsResponse.Slice.DataPoint" = proto.Field( + proto.MESSAGE, + number=2, + message="QueryMetricsResponse.Slice.DataPoint", + ) + time_series: "QueryMetricsResponse.Slice.TimeSeries" = proto.Field( + proto.MESSAGE, + number=3, + message="QueryMetricsResponse.Slice.TimeSeries", + ) + + location: str = proto.Field( + proto.STRING, + number=1, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + slices: MutableSequence[Slice] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=Slice, + ) + macro_average_slice: Slice = proto.Field( + proto.MESSAGE, + number=4, + optional=True, + message=Slice, + ) + + +class QueryMetricsMetadata(proto.Message): + r"""The metadata from querying metrics.""" + + +class CreateQaQuestionRequest(proto.Message): + r"""The request for creating a QaQuestion. + + Attributes: + parent (str): + Required. The parent resource of the + QaQuestion. + qa_question (google.cloud.contact_center_insights_v1.types.QaQuestion): + Required. The QaQuestion to create. + qa_question_id (str): + Optional. A unique ID for the new question. This ID will + become the final component of the question's resource name. + If no ID is specified, a server-generated ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid characters + are ``[a-z][0-9]-``. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + qa_question: resources.QaQuestion = proto.Field( + proto.MESSAGE, + number=2, + message=resources.QaQuestion, + ) + qa_question_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class GetQaQuestionRequest(proto.Message): + r"""The request for a QaQuestion. + + Attributes: + name (str): + Required. The name of the QaQuestion to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListQaQuestionsRequest(proto.Message): + r"""Request to list QaQuestions. + + Attributes: + parent (str): + Required. The parent resource of the + questions. + page_size (int): + Optional. The maximum number of questions to return in the + response. If the value is zero, the service will select a + default size. A call might return fewer objects than + requested. A non-empty ``next_page_token`` in the response + indicates that more data is available. + page_token (str): + Optional. The value returned by the last + ``ListQaQuestionsResponse``. This value indicates that this + is a continuation of a prior ``ListQaQuestions`` call and + that the system should return the next page of data. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListQaQuestionsResponse(proto.Message): + r"""The response from a ListQaQuestions request. + + Attributes: + qa_questions (MutableSequence[google.cloud.contact_center_insights_v1.types.QaQuestion]): + The QaQuestions under the parent. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + qa_questions: MutableSequence[resources.QaQuestion] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.QaQuestion, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateQaQuestionRequest(proto.Message): + r"""The request for updating a QaQuestion. + + Attributes: + qa_question (google.cloud.contact_center_insights_v1.types.QaQuestion): + Required. The QaQuestion to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. All possible + fields can be updated by passing ``*``, or a subset of the + following updateable fields can be provided: + + - ``abbreviation`` + - ``answer_choices`` + - ``answer_instructions`` + - ``order`` + - ``question_body`` + - ``tags`` + """ + + qa_question: resources.QaQuestion = proto.Field( + proto.MESSAGE, + number=1, + message=resources.QaQuestion, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteQaQuestionRequest(proto.Message): + r"""The request for deleting a QaQuestion. + + Attributes: + name (str): + Required. The name of the QaQuestion to + delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateQaScorecardRequest(proto.Message): + r"""The request for creating a QaScorecard. + + Attributes: + parent (str): + Required. The parent resource of the + QaScorecard. + qa_scorecard (google.cloud.contact_center_insights_v1.types.QaScorecard): + Required. The QaScorecard to create. + qa_scorecard_id (str): + Optional. A unique ID for the new QaScorecard. This ID will + become the final component of the QaScorecard's resource + name. If no ID is specified, a server-generated ID will be + used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid characters + are ``[a-z][0-9]-``. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + qa_scorecard: resources.QaScorecard = proto.Field( + proto.MESSAGE, + number=2, + message=resources.QaScorecard, + ) + qa_scorecard_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class GetQaScorecardRequest(proto.Message): + r"""The request for a QaScorecard. By default, returns the latest + revision. + + Attributes: + name (str): + Required. The name of the QaScorecard to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateQaScorecardRequest(proto.Message): + r"""The request for updating a QaScorecard. + + Attributes: + qa_scorecard (google.cloud.contact_center_insights_v1.types.QaScorecard): + Required. The QaScorecard to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. All possible + fields can be updated by passing ``*``, or a subset of the + following updateable fields can be provided: + + - ``description`` + - ``display_name`` + """ + + qa_scorecard: resources.QaScorecard = proto.Field( + proto.MESSAGE, + number=1, + message=resources.QaScorecard, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteQaScorecardRequest(proto.Message): + r"""The request for deleting a QaScorecard. + + Attributes: + name (str): + Required. The name of the QaScorecard to + delete. + force (bool): + Optional. If set to true, all of this + QaScorecard's child resources will also be + deleted. Otherwise, the request will only + succeed if it has none. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + force: bool = proto.Field( + proto.BOOL, + number=2, + ) + + +class CreateQaScorecardRevisionRequest(proto.Message): + r"""The request for creating a QaScorecardRevision. + + Attributes: + parent (str): + Required. The parent resource of the + QaScorecardRevision. + qa_scorecard_revision (google.cloud.contact_center_insights_v1.types.QaScorecardRevision): + Required. The QaScorecardRevision to create. + qa_scorecard_revision_id (str): + Optional. A unique ID for the new QaScorecardRevision. This + ID will become the final component of the + QaScorecardRevision's resource name. If no ID is specified, + a server-generated ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid characters + are ``[a-z][0-9]-``. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + qa_scorecard_revision: resources.QaScorecardRevision = proto.Field( + proto.MESSAGE, + number=2, + message=resources.QaScorecardRevision, + ) + qa_scorecard_revision_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class GetQaScorecardRevisionRequest(proto.Message): + r"""The request for a QaScorecardRevision. + + Attributes: + name (str): + Required. The name of the QaScorecardRevision + to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class TuneQaScorecardRevisionRequest(proto.Message): + r"""Request for TuneQaScorecardRevision endpoint. + + Attributes: + parent (str): + Required. The parent resource for new fine + tuning job instance. + filter (str): + Required. Filter for selecting the feedback + labels that needs to be used for training. + This filter can be used to limit the feedback + labels used for tuning to a feedback labels + created or updated for a specific time-window + etc. + validate_only (bool): + Optional. Run in validate only mode, no fine + tuning will actually run. Data quality + validations like training data distributions + will run. Even when set to false, the data + quality validations will still run but once the + validations complete we will proceed with the + fine tune, if applicable. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + filter: str = proto.Field( + proto.STRING, + number=2, + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class TuneQaScorecardRevisionResponse(proto.Message): + r"""Response for TuneQaScorecardRevision endpoint.""" + + +class TuneQaScorecardRevisionMetadata(proto.Message): + r"""Metadata for TuneQaScorecardRevision endpoint. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionRequest): + Output only. The original request. + qa_question_dataset_validation_results (MutableSequence[google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionMetadata.QaQuestionDatasetValidationResult]): + Output only. The results of data validation + per question in the request. + qa_question_dataset_tuning_metrics (MutableSequence[google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionMetadata.QaQuestionDatasetTuningMetrics]): + Output only. The metrics for each QaQuestion + in the TuneScorecardRevision request. + tuning_completion_ratio (float): + Output only. The percentage of the tuning job + that has completed. Always between 0 and 1 where + 0 indicates the job has not started i.e. 0% and + 1 indicates the job has completed i.e. 100%. + """ + + class QaQuestionDatasetValidationResult(proto.Message): + r"""Contains validation results for a question in the tuning + request. + + Attributes: + question (str): + Output only. The resource path of the + question whose dataset was evaluated for tuning. + dataset_validation_warnings (MutableSequence[google.cloud.contact_center_insights_v1.types.DatasetValidationWarning]): + A list of any applicable data validation + warnings about the question's feedback labels. + valid_feedback_labels_count (int): + The number of valid feedback labels in the + question's dataset. + """ + + question: str = proto.Field( + proto.STRING, + number=1, + ) + dataset_validation_warnings: MutableSequence[ + resources.DatasetValidationWarning + ] = proto.RepeatedField( + proto.ENUM, + number=2, + enum=resources.DatasetValidationWarning, + ) + valid_feedback_labels_count: int = proto.Field( + proto.INT32, + number=3, + ) + + class QaQuestionDatasetTuningMetrics(proto.Message): + r"""Contains performance metrics for each QaQuestion in the + TuneScorecardRevision request. + + Attributes: + question (str): + Output only. The resource path of the + question whose dataset was evaluated for tuning. + metrics (google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionMetadata.QaQuestionDatasetTuningMetrics.Metrics): + Output only. The metrics for the question's + dataset. + """ + + class Metrics(proto.Message): + r"""Performance metrics for the question's dataset calculated + over the tuned model. + + Attributes: + accuracy (float): + Accuracy of the question's dataset. + """ + + accuracy: float = proto.Field( + proto.DOUBLE, + number=1, + ) + + question: str = proto.Field( + proto.STRING, + number=1, + ) + metrics: "TuneQaScorecardRevisionMetadata.QaQuestionDatasetTuningMetrics.Metrics" = proto.Field( + proto.MESSAGE, + number=2, + message="TuneQaScorecardRevisionMetadata.QaQuestionDatasetTuningMetrics.Metrics", + ) + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: "TuneQaScorecardRevisionRequest" = proto.Field( + proto.MESSAGE, + number=3, + message="TuneQaScorecardRevisionRequest", + ) + qa_question_dataset_validation_results: MutableSequence[ + QaQuestionDatasetValidationResult + ] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=QaQuestionDatasetValidationResult, + ) + qa_question_dataset_tuning_metrics: MutableSequence[ + QaQuestionDatasetTuningMetrics + ] = proto.RepeatedField( + proto.MESSAGE, + number=5, + message=QaQuestionDatasetTuningMetrics, + ) + tuning_completion_ratio: float = proto.Field( + proto.DOUBLE, + number=6, + ) + + +class DeployQaScorecardRevisionRequest(proto.Message): + r"""The request to deploy a QaScorecardRevision + + Attributes: + name (str): + Required. The name of the QaScorecardRevision + to deploy. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UndeployQaScorecardRevisionRequest(proto.Message): + r"""The request to undeploy a QaScorecardRevision + + Attributes: + name (str): + Required. The name of the QaScorecardRevision + to undeploy. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteQaScorecardRevisionRequest(proto.Message): + r"""The request to delete a QaScorecardRevision. + + Attributes: + name (str): + Required. The name of the QaScorecardRevision + to delete. + force (bool): + Optional. If set to true, all of this + QaScorecardRevision's child resources will also + be deleted. Otherwise, the request will only + succeed if it has none. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + force: bool = proto.Field( + proto.BOOL, + number=2, + ) + + +class ListQaScorecardsRequest(proto.Message): + r"""Request to list QaScorecards. + + Attributes: + parent (str): + Required. The parent resource of the + scorecards. + page_size (int): + Optional. The maximum number of scorecards to return in the + response. If the value is zero, the service will select a + default size. A call might return fewer objects than + requested. A non-empty ``next_page_token`` in the response + indicates that more data is available. + page_token (str): + Optional. The value returned by the last + ``ListQaScorecardsResponse``. This value indicates that this + is a continuation of a prior ``ListQaScorecards`` call and + that the system should return the next page of data. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListQaScorecardsResponse(proto.Message): + r"""The response from a ListQaScorecards request. + + Attributes: + qa_scorecards (MutableSequence[google.cloud.contact_center_insights_v1.types.QaScorecard]): + The QaScorecards under the parent. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + qa_scorecards: MutableSequence[resources.QaScorecard] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.QaScorecard, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class ListQaScorecardRevisionsRequest(proto.Message): + r"""Request to list QaScorecardRevisions + + Attributes: + parent (str): + Required. The parent resource of the + scorecard revisions. To list all revisions of + all scorecards, substitute the QaScorecard ID + with a '-' character. + page_size (int): + Optional. The maximum number of scorecard revisions to + return in the response. If the value is zero, the service + will select a default size. A call might return fewer + objects than requested. A non-empty ``next_page_token`` in + the response indicates that more data is available. + page_token (str): + Optional. The value returned by the last + ``ListQaScorecardRevisionsResponse``. This value indicates + that this is a continuation of a prior + ``ListQaScorecardRevisions`` call and that the system should + return the next page of data. + filter (str): + Optional. A filter to reduce results to a + specific subset. Useful for querying scorecard + revisions with specific properties. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListQaScorecardRevisionsResponse(proto.Message): + r"""The response from a ListQaScorecardRevisions request. + + Attributes: + qa_scorecard_revisions (MutableSequence[google.cloud.contact_center_insights_v1.types.QaScorecardRevision]): + The QaScorecards under the parent. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + qa_scorecard_revisions: MutableSequence[ + resources.QaScorecardRevision + ] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.QaScorecardRevision, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class CreateFeedbackLabelRequest(proto.Message): + r"""The request for creating a feedback label. + + Attributes: + parent (str): + Required. The parent resource of the feedback + label. + feedback_label_id (str): + Optional. The ID of the feedback label to + create. If one is not specified it will be + generated by the server. + feedback_label (google.cloud.contact_center_insights_v1.types.FeedbackLabel): + Required. The feedback label to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + feedback_label_id: str = proto.Field( + proto.STRING, + number=2, + ) + feedback_label: resources.FeedbackLabel = proto.Field( + proto.MESSAGE, + number=3, + message=resources.FeedbackLabel, + ) + + +class ListFeedbackLabelsRequest(proto.Message): + r"""The request for listing feedback labels. + + Attributes: + parent (str): + Required. The parent resource of the feedback + labels. + filter (str): + Optional. A filter to reduce results to a specific subset. + Supports disjunctions (OR) and conjunctions (AND). + Automatically sorts by conversation ID. To sort by all + feedback labels in a project see ListAllFeedbackLabels. + + Supported fields: + + - ``issue_model_id`` + - ``qa_question_id`` + - ``qa_scorecard_id`` + - ``min_create_time`` + - ``max_create_time`` + - ``min_update_time`` + - ``max_update_time`` + - ``feedback_label_type``: QUALITY_AI, TOPIC_MODELING + page_size (int): + Optional. The maximum number of feedback + labels to return in the response. A valid page + size ranges from 0 to 100,000 inclusive. If the + page size is zero or unspecified, a default page + size of 100 will be chosen. Note that a call + might return fewer results than the requested + page size. + page_token (str): + Optional. The value returned by the last + ``ListFeedbackLabelsResponse``. This value indicates that + this is a continuation of a prior ``ListFeedbackLabels`` + call and that the system should return the next page of + data. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + filter: str = proto.Field( + proto.STRING, + number=2, + ) + page_size: int = proto.Field( + proto.INT32, + number=3, + ) + page_token: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListFeedbackLabelsResponse(proto.Message): + r"""The response for listing feedback labels. + + Attributes: + feedback_labels (MutableSequence[google.cloud.contact_center_insights_v1.types.FeedbackLabel]): + The feedback labels that match the request. + next_page_token (str): + The next page token. + """ + + @property + def raw_page(self): + return self + + feedback_labels: MutableSequence[resources.FeedbackLabel] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.FeedbackLabel, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetFeedbackLabelRequest(proto.Message): + r"""The request for getting a feedback label. + + Attributes: + name (str): + Required. The name of the feedback label to + get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateFeedbackLabelRequest(proto.Message): + r"""The request for updating a feedback label. + + Attributes: + feedback_label (google.cloud.contact_center_insights_v1.types.FeedbackLabel): + Required. The feedback label to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. + """ + + feedback_label: resources.FeedbackLabel = proto.Field( + proto.MESSAGE, + number=1, + message=resources.FeedbackLabel, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteFeedbackLabelRequest(proto.Message): + r"""The request for deleting a feedback label. + + Attributes: + name (str): + Required. The name of the feedback label to + delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListAllFeedbackLabelsRequest(proto.Message): + r"""The request for listing all feedback labels. + + Attributes: + parent (str): + Required. The parent resource of all feedback + labels per project. + page_size (int): + Optional. The maximum number of feedback + labels to return in the response. A valid page + size ranges from 0 to 100,000 inclusive. If the + page size is zero or unspecified, a default page + size of 100 will be chosen. Note that a call + might return fewer results than the requested + page size. + page_token (str): + Optional. The value returned by the last + ``ListAllFeedbackLabelsResponse``. This value indicates that + this is a continuation of a prior ``ListAllFeedbackLabels`` + call and that the system should return the next page of + data. + filter (str): + Optional. A filter to reduce results to a specific subset in + the entire project. Supports disjunctions (OR) and + conjunctions (AND). + + Supported fields: + + - ``issue_model_id`` + - ``qa_question_id`` + - ``min_create_time`` + - ``max_create_time`` + - ``min_update_time`` + - ``max_update_time`` + - ``feedback_label_type``: QUALITY_AI, TOPIC_MODELING + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListAllFeedbackLabelsResponse(proto.Message): + r"""The response for listing all feedback labels. + + Attributes: + feedback_labels (MutableSequence[google.cloud.contact_center_insights_v1.types.FeedbackLabel]): + The feedback labels that match the request. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + feedback_labels: MutableSequence[resources.FeedbackLabel] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.FeedbackLabel, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class BulkUploadFeedbackLabelsRequest(proto.Message): + r"""The request for bulk uploading feedback labels. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + gcs_source (google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsRequest.GcsSource): + A cloud storage bucket source. + + This field is a member of `oneof`_ ``source``. + parent (str): + Required. The parent resource for new + feedback labels. + validate_only (bool): + Optional. If set, upload will not happen and + the labels will be validated. If not set, then + default behavior will be to upload the labels + after validation is complete. + """ + + class GcsSource(proto.Message): + r"""Google Cloud Storage Object details to get the feedback label + file from. + + Attributes: + format_ (google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsRequest.GcsSource.Format): + Required. File format which will be ingested. + object_uri (str): + Required. The Google Cloud Storage URI of the file to + import. Format: ``gs://bucket_name/object_name`` + """ + + class Format(proto.Enum): + r"""All permissible file formats. + + Values: + FORMAT_UNSPECIFIED (0): + Unspecified format. + CSV (1): + CSV format. + JSON (2): + JSON format. + """ + FORMAT_UNSPECIFIED = 0 + CSV = 1 + JSON = 2 + + format_: "BulkUploadFeedbackLabelsRequest.GcsSource.Format" = proto.Field( + proto.ENUM, + number=1, + enum="BulkUploadFeedbackLabelsRequest.GcsSource.Format", + ) + object_uri: str = proto.Field( + proto.STRING, + number=2, + ) + + gcs_source: GcsSource = proto.Field( + proto.MESSAGE, + number=2, + oneof="source", + message=GcsSource, + ) + parent: str = proto.Field( + proto.STRING, + number=1, + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class BulkUploadFeedbackLabelsResponse(proto.Message): + r"""Response for the Bulk Upload Feedback Labels API.""" + + +class BulkUploadFeedbackLabelsMetadata(proto.Message): + r"""Metadata for the Bulk Upload Feedback Labels API. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsRequest): + Output only. The original request for ingest. + partial_errors (MutableSequence[google.rpc.status_pb2.Status]): + Partial errors during ingest operation that + might cause the operation output to be + incomplete. + upload_stats (google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsMetadata.UploadStats): + Output only. Statistics for + BulkUploadFeedbackLabels operation. + """ + + class UploadStats(proto.Message): + r"""Statistics for BulkUploadFeedbackLabels operation. + + Attributes: + processed_object_count (int): + The number of objects processed during the + upload operation. + failed_validation_count (int): + The number of objects skipped because of + failed validation + successful_upload_count (int): + The number of new feedback labels added + during this ingest operation. + """ + + processed_object_count: int = proto.Field( + proto.INT32, + number=1, + ) + failed_validation_count: int = proto.Field( + proto.INT32, + number=2, + ) + successful_upload_count: int = proto.Field( + proto.INT32, + number=3, + ) + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: "BulkUploadFeedbackLabelsRequest" = proto.Field( + proto.MESSAGE, + number=3, + message="BulkUploadFeedbackLabelsRequest", + ) + partial_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=status_pb2.Status, + ) + upload_stats: UploadStats = proto.Field( + proto.MESSAGE, + number=5, + message=UploadStats, + ) + + +class BulkDownloadFeedbackLabelsRequest(proto.Message): + r"""Request for the BulkDownloadFeedbackLabel endpoint. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + gcs_destination (google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest.GcsDestination): + A cloud storage bucket destination. + + This field is a member of `oneof`_ ``destination``. + parent (str): + Required. The parent resource for new + feedback labels. + filter (str): + Optional. A filter to reduce results to a specific subset. + Supports disjunctions (OR) and conjunctions (AND). + + Supported fields: + + - ``issue_model_id`` + - ``qa_question_id`` + - ``qa_scorecard_id`` + - ``min_create_time`` + - ``max_create_time`` + - ``min_update_time`` + - ``max_update_time`` + - ``feedback_label_type``: QUALITY_AI, TOPIC_MODELING + max_download_count (int): + Optional. Limits the maximum number of feedback labels that + will be downloaded. The first ``N`` feedback labels will be + downloaded. + feedback_label_type (google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest.FeedbackLabelType): + Optional. The type of feedback labels that + will be downloaded. + conversation_filter (str): + Optional. Filter parent conversations to download feedback + labels for. When specified, the feedback labels will be + downloaded for the conversations that match the filter. If + ``template_qa_scorecard_id`` is set, all the conversations + that match the filter will be paired with the questions + under the scorecard for labeling. + template_qa_scorecard_id (MutableSequence[str]): + Optional. If set, a template for labeling conversations and + scorecard questions will be created from the + conversation_filter and the questions under the + scorecard(s). The feedback label ``filter`` will be ignored. + """ + + class FeedbackLabelType(proto.Enum): + r"""Possible feedback label types that will be downloaded. + + Values: + FEEDBACK_LABEL_TYPE_UNSPECIFIED (0): + Unspecified format + QUALITY_AI (1): + Downloaded file will contain all Quality AI + labels from the latest scorecard revision. + TOPIC_MODELING (2): + Downloaded file will contain only Topic + Modeling labels. + """ + FEEDBACK_LABEL_TYPE_UNSPECIFIED = 0 + QUALITY_AI = 1 + TOPIC_MODELING = 2 + + class GcsDestination(proto.Message): + r"""Google Cloud Storage Object details to write the feedback + labels to. + + Attributes: + format_ (google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest.GcsDestination.Format): + Required. File format in which the labels + will be exported. + object_uri (str): + Required. The Google Cloud Storage URI to write the feedback + labels to. The file name will be used as a prefix for the + files written to the bucket if the output needs to be split + across multiple files, otherwise it will be used as is. The + file extension will be appended to the file name based on + the format selected. E.g. + ``gs://bucket_name/object_uri_prefix`` + add_whitespace (bool): + Optional. Add whitespace to the JSON file. + Makes easier to read, but increases file size. + Only applicable for JSON format. + always_print_empty_fields (bool): + Optional. Always print fields with no + presence. This is useful for printing fields + that are not set, like implicit 0 value or empty + lists/maps. Only applicable for JSON format. + records_per_file_count (int): + Optional. The number of records per file. + Applicable for either format. + """ + + class Format(proto.Enum): + r"""All permissible file formats. See ``records_per_file_count`` to + override the default number of records per file. + + Values: + FORMAT_UNSPECIFIED (0): + Unspecified format. + CSV (1): + CSV format. + 1,000 labels are stored per CSV file by default. + JSON (2): + JSON format. + 1 label stored per JSON file by default. + """ + FORMAT_UNSPECIFIED = 0 + CSV = 1 + JSON = 2 + + format_: "BulkDownloadFeedbackLabelsRequest.GcsDestination.Format" = ( + proto.Field( + proto.ENUM, + number=1, + enum="BulkDownloadFeedbackLabelsRequest.GcsDestination.Format", + ) + ) + object_uri: str = proto.Field( + proto.STRING, + number=2, + ) + add_whitespace: bool = proto.Field( + proto.BOOL, + number=3, + ) + always_print_empty_fields: bool = proto.Field( + proto.BOOL, + number=4, + ) + records_per_file_count: int = proto.Field( + proto.INT64, + number=5, + ) + + gcs_destination: GcsDestination = proto.Field( + proto.MESSAGE, + number=3, + oneof="destination", + message=GcsDestination, + ) + parent: str = proto.Field( + proto.STRING, + number=1, + ) + filter: str = proto.Field( + proto.STRING, + number=2, + ) + max_download_count: int = proto.Field( + proto.INT32, + number=4, + ) + feedback_label_type: FeedbackLabelType = proto.Field( + proto.ENUM, + number=5, + enum=FeedbackLabelType, + ) + conversation_filter: str = proto.Field( + proto.STRING, + number=6, + ) + template_qa_scorecard_id: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=7, + ) + + +class BulkDownloadFeedbackLabelsResponse(proto.Message): + r"""Response for the BulkDownloadFeedbackLabel endpoint.""" + + +class BulkDownloadFeedbackLabelsMetadata(proto.Message): + r"""Metadata for the BulkDownloadFeedbackLabel endpoint. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest): + Output only. The original request for + download. + partial_errors (MutableSequence[google.rpc.status_pb2.Status]): + Partial errors during ingest operation that + might cause the operation output to be + incomplete. + download_stats (google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsMetadata.DownloadStats): + Output only. Statistics for + BulkDownloadFeedbackLabels operation. + """ + + class DownloadStats(proto.Message): + r"""Statistics for BulkDownloadFeedbackLabels operation. + + Attributes: + processed_object_count (int): + The number of objects processed during the + download operation. + successful_download_count (int): + The number of new feedback labels downloaded + during this operation. Different from + "processed" because some labels might not be + downloaded because an error. + total_files_written (int): + Total number of files written to the provided + Cloud Storage bucket. + file_names (MutableSequence[str]): + Output only. Full name of the files written + to Cloud storage. + """ + + processed_object_count: int = proto.Field( + proto.INT32, + number=1, + ) + successful_download_count: int = proto.Field( + proto.INT32, + number=2, + ) + total_files_written: int = proto.Field( + proto.INT32, + number=3, + ) + file_names: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: "BulkDownloadFeedbackLabelsRequest" = proto.Field( + proto.MESSAGE, + number=3, + message="BulkDownloadFeedbackLabelsRequest", + ) + partial_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=status_pb2.Status, + ) + download_stats: DownloadStats = proto.Field( + proto.MESSAGE, + number=5, + message=DownloadStats, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py index 83de2aec7b7e..c66c651e5e83 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py @@ -24,6 +24,7 @@ __protobuf__ = proto.module( package="google.cloud.contactcenterinsights.v1", manifest={ + "DatasetValidationWarning", "Conversation", "Analysis", "ConversationDataSource", @@ -31,6 +32,7 @@ "DialogflowSource", "AnalysisResult", "IssueModelResult", + "FeedbackLabel", "ConversationLevelSentiment", "ConversationLevelSilence", "IssueAssignment", @@ -56,6 +58,7 @@ "PhraseMatchRuleConfig", "ExactMatchConfig", "Settings", + "AnalysisRule", "EncryptionSpec", "RedactionConfig", "SpeechConfig", @@ -70,10 +73,43 @@ "ConversationParticipant", "View", "AnnotatorSelector", + "QaQuestion", + "QaScorecard", + "QaScorecardRevision", + "QaAnswer", + "QaScorecardResult", }, ) +class DatasetValidationWarning(proto.Enum): + r"""Enum for the different types of issues a tuning dataset can + have. These warnings are currentlyraised when trying to validate + a dataset for tuning a scorecard. + + Values: + DATASET_VALIDATION_WARNING_UNSPECIFIED (0): + Unspecified data validation warning. + TOO_MANY_INVALID_FEEDBACK_LABELS (1): + A non-trivial percentage of the feedback + labels are invalid. + INSUFFICIENT_FEEDBACK_LABELS (2): + The quantity of valid feedback labels + provided is less than the recommended minimum. + INSUFFICIENT_FEEDBACK_LABELS_PER_ANSWER (3): + One or more of the answers have less than the + recommended minimum of feedback labels. + ALL_FEEDBACK_LABELS_HAVE_THE_SAME_ANSWER (4): + All the labels in the dataset come from a + single answer choice. + """ + DATASET_VALIDATION_WARNING_UNSPECIFIED = 0 + TOO_MANY_INVALID_FEEDBACK_LABELS = 1 + INSUFFICIENT_FEEDBACK_LABELS = 2 + INSUFFICIENT_FEEDBACK_LABELS_PER_ANSWER = 3 + ALL_FEEDBACK_LABELS_HAVE_THE_SAME_ANSWER = 4 + + class Conversation(proto.Message): r"""The conversation resource. @@ -125,17 +161,17 @@ class Conversation(proto.Message): the human agent who handled the conversation. labels (MutableMapping[str, str]): A map for the user to specify any custom - fields. A maximum of 20 labels per conversation + fields. A maximum of 100 labels per conversation is allowed, with a maximum of 256 characters per entry. quality_metadata (google.cloud.contact_center_insights_v1.types.Conversation.QualityMetadata): Conversation metadata related to quality management. metadata_json (str): - Input only. JSON Metadata encoded as a + Input only. JSON metadata encoded as a string. This field is primarily used by Insights integrations with various telphony systems and - must be in one of Insights' supported formats. + must be in one of Insight's supported formats. transcript (google.cloud.contact_center_insights_v1.types.Conversation.Transcript): Output only. The conversation transcript. medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): @@ -712,6 +748,8 @@ class CallAnalysisMetadata(proto.Message): issue_model_result (google.cloud.contact_center_insights_v1.types.IssueModelResult): Overall conversation-level issue modeling result. + qa_scorecard_results (MutableSequence[google.cloud.contact_center_insights_v1.types.QaScorecardResult]): + Results of scoring QaScorecards. """ annotations: MutableSequence["CallAnnotation"] = proto.RepeatedField( @@ -752,6 +790,13 @@ class CallAnalysisMetadata(proto.Message): number=8, message="IssueModelResult", ) + qa_scorecard_results: MutableSequence[ + "QaScorecardResult" + ] = proto.RepeatedField( + proto.MESSAGE, + number=10, + message="QaScorecardResult", + ) call_analysis_metadata: CallAnalysisMetadata = proto.Field( proto.MESSAGE, @@ -788,6 +833,68 @@ class IssueModelResult(proto.Message): ) +class FeedbackLabel(proto.Message): + r"""Represents a conversation, resource, and label provided by + the user. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + label (str): + String label. + + This field is a member of `oneof`_ ``label_type``. + qa_answer_label (google.cloud.contact_center_insights_v1.types.QaAnswer.AnswerValue): + QaAnswer label. + + This field is a member of `oneof`_ ``label_type``. + name (str): + Immutable. Resource name of the FeedbackLabel. Format: + projects/{project}/locations/{location}/conversations/{conversation}/feedbackLabels/{feedback_label} + labeled_resource (str): + Resource name of the resource to be labeled. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create time of the label. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Update time of the label. + """ + + label: str = proto.Field( + proto.STRING, + number=4, + oneof="label_type", + ) + qa_answer_label: "QaAnswer.AnswerValue" = proto.Field( + proto.MESSAGE, + number=7, + oneof="label_type", + message="QaAnswer.AnswerValue", + ) + name: str = proto.Field( + proto.STRING, + number=1, + ) + labeled_resource: str = proto.Field( + proto.STRING, + number=3, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + + class ConversationLevelSentiment(proto.Message): r"""One channel of conversation-level sentiment data. @@ -1960,9 +2067,92 @@ class AnalysisConfig(proto.Message): ) +class AnalysisRule(proto.Message): + r"""The CCAI Insights project wide analysis rule. This rule will + be applied to all conversations that match the filter defined in + the rule. For a conversation matches the filter, the annotators + specified in the rule will be run. If a conversation matches + multiple rules, a union of all the annotators will be run. One + project can have multiple analysis rules. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. The resource name of the analysis rule. Format: + projects/{project}/locations/{location}/analysisRules/{analysis_rule} + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this analysis + rule was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + this analysis rule was updated. + display_name (str): + Display Name of the analysis rule. + + This field is a member of `oneof`_ ``_display_name``. + conversation_filter (str): + Filter for the conversations that should + apply this analysis rule. An empty filter means + this analysis rule applies to all conversations. + annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): + Selector of annotators to run and the phrase matchers to use + for conversations that matches the conversation_filter. If + not specified, NO annotators will be run. + analysis_percentage (float): + Percentage of conversations that we should apply this + analysis setting automatically, between [0, 1]. For example, + 0.1 means 10%. Conversations are sampled in a determenestic + way. The original runtime_percentage & upload percentage + will be replaced by defining filters on the conversation. + active (bool): + If true, apply this rule to conversations. + Otherwise, this rule is inactive and saved as a + draft. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + display_name: str = proto.Field( + proto.STRING, + number=4, + optional=True, + ) + conversation_filter: str = proto.Field( + proto.STRING, + number=5, + ) + annotator_selector: "AnnotatorSelector" = proto.Field( + proto.MESSAGE, + number=6, + message="AnnotatorSelector", + ) + analysis_percentage: float = proto.Field( + proto.DOUBLE, + number=7, + ) + active: bool = proto.Field( + proto.BOOL, + number=8, + ) + + class EncryptionSpec(proto.Message): - r"""A customer-managed encryption key specification that can be - applied to all created resources (e.g. Conversation). + r"""A customer-managed encryption key specification that can be applied + to all created resources (e.g. ``Conversation``). Attributes: name (str): @@ -1973,9 +2163,9 @@ class EncryptionSpec(proto.Message): kms_key (str): Required. The name of customer-managed encryption key that is used to secure a resource and its sub-resources. If - empty, the resource is secured by the default Google - encryption key. Only the key in the same location as this - resource is allowed to be used for encryption. Format: + empty, the resource is secured by our default encryption + key. Only the key in the same location as this resource is + allowed to be used for encryption. Format: ``projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{key}`` """ @@ -2685,6 +2875,10 @@ class AnnotatorSelector(proto.Message): summarization_config (google.cloud.contact_center_insights_v1.types.AnnotatorSelector.SummarizationConfig): Configuration for the summarization annotator. + run_qa_annotator (bool): + Whether to run the QA annotator. + qa_config (google.cloud.contact_center_insights_v1.types.AnnotatorSelector.QaConfig): + Configuration for the QA annotator. """ class SummarizationConfig(proto.Message): @@ -2737,6 +2931,38 @@ class SummarizationModel(proto.Enum): enum="AnnotatorSelector.SummarizationConfig.SummarizationModel", ) + class QaConfig(proto.Message): + r"""Configuration for the QA feature. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + scorecard_list (google.cloud.contact_center_insights_v1.types.AnnotatorSelector.QaConfig.ScorecardList): + A manual list of scorecards to score. + + This field is a member of `oneof`_ ``scorecard_source``. + """ + + class ScorecardList(proto.Message): + r"""Container for a list of scorecards. + + Attributes: + qa_scorecard_revisions (MutableSequence[str]): + List of QaScorecardRevisions. + """ + + qa_scorecard_revisions: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=1, + ) + + scorecard_list: "AnnotatorSelector.QaConfig.ScorecardList" = proto.Field( + proto.MESSAGE, + number=1, + oneof="scorecard_source", + message="AnnotatorSelector.QaConfig.ScorecardList", + ) + run_interruption_annotator: bool = proto.Field( proto.BOOL, number=1, @@ -2782,6 +3008,762 @@ class SummarizationModel(proto.Enum): number=11, message=SummarizationConfig, ) + run_qa_annotator: bool = proto.Field( + proto.BOOL, + number=12, + ) + qa_config: QaConfig = proto.Field( + proto.MESSAGE, + number=13, + message=QaConfig, + ) + + +class QaQuestion(proto.Message): + r"""A single question to be scored by the Insights QA feature. + + Attributes: + name (str): + Identifier. The resource name of the question. Format: + projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}/revisions/{revision}/qaQuestions/{qa_question} + abbreviation (str): + Short, descriptive string, used in the UI + where it's not practical to display the full + question body. E.g., "Greeting". + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this question + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the question was updated. + question_body (str): + Question text. E.g., "Did the agent greet the + customer?". + answer_instructions (str): + Instructions describing how to determine the + answer. + answer_choices (MutableSequence[google.cloud.contact_center_insights_v1.types.QaQuestion.AnswerChoice]): + A list of valid answers to the question, + which the LLM must choose from. + tags (MutableSequence[str]): + User-defined list of arbitrary tags for the + question. Used for grouping/organization and for + weighting the score of each question. + order (int): + Defines the order of the question within its + parent scorecard revision. + metrics (google.cloud.contact_center_insights_v1.types.QaQuestion.Metrics): + Metrics of the underlying tuned LLM over a + holdout/test set while fine tuning the + underlying LLM for the given question. This + field will only be populated if and only if the + question is part of a scorecard revision that + has been tuned. + tuning_metadata (google.cloud.contact_center_insights_v1.types.QaQuestion.TuningMetadata): + Metadata about the tuning operation for the + question.This field will only be populated if + and only if the question is part of a scorecard + revision that has been tuned. + """ + + class AnswerChoice(proto.Message): + r"""Message representing a possible answer to the question. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + str_value (str): + String value. + + This field is a member of `oneof`_ ``value``. + num_value (float): + Numerical value. + + This field is a member of `oneof`_ ``value``. + bool_value (bool): + Boolean value. + + This field is a member of `oneof`_ ``value``. + na_value (bool): + A value of "Not Applicable (N/A)". If provided, this field + may only be set to ``true``. If a question receives this + answer, it will be excluded from any score calculations. + + This field is a member of `oneof`_ ``value``. + key (str): + A short string used as an identifier. + score (float): + Numerical score of the answer, used for generating the + overall score of a QaScorecardResult. If the answer uses + na_value, this field is unused. + + This field is a member of `oneof`_ ``_score``. + """ + + str_value: str = proto.Field( + proto.STRING, + number=2, + oneof="value", + ) + num_value: float = proto.Field( + proto.DOUBLE, + number=3, + oneof="value", + ) + bool_value: bool = proto.Field( + proto.BOOL, + number=4, + oneof="value", + ) + na_value: bool = proto.Field( + proto.BOOL, + number=5, + oneof="value", + ) + key: str = proto.Field( + proto.STRING, + number=1, + ) + score: float = proto.Field( + proto.DOUBLE, + number=6, + optional=True, + ) + + class Metrics(proto.Message): + r"""A wrapper representing metrics calculated against a test-set + on a LLM that was fine tuned for this question. + + Attributes: + accuracy (float): + Output only. Accuracy of the model. Measures + the percentage of correct answers the model gave + on the test set. + """ + + accuracy: float = proto.Field( + proto.DOUBLE, + number=1, + ) + + class TuningMetadata(proto.Message): + r"""Metadata about the tuning operation for the question. Will + only be set if a scorecard containing this question has been + tuned. + + Attributes: + total_valid_label_count (int): + Total number of valid labels provided for the + question at the time of tuining. + dataset_validation_warnings (MutableSequence[google.cloud.contact_center_insights_v1.types.DatasetValidationWarning]): + A list of any applicable data validation + warnings about the question's feedback labels. + tuning_error (str): + Error status of the tuning operation for the + question. Will only be set if the tuning + operation failed. + """ + + total_valid_label_count: int = proto.Field( + proto.INT64, + number=1, + ) + dataset_validation_warnings: MutableSequence[ + "DatasetValidationWarning" + ] = proto.RepeatedField( + proto.ENUM, + number=2, + enum="DatasetValidationWarning", + ) + tuning_error: str = proto.Field( + proto.STRING, + number=3, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + abbreviation: str = proto.Field( + proto.STRING, + number=2, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + question_body: str = proto.Field( + proto.STRING, + number=5, + ) + answer_instructions: str = proto.Field( + proto.STRING, + number=9, + ) + answer_choices: MutableSequence[AnswerChoice] = proto.RepeatedField( + proto.MESSAGE, + number=6, + message=AnswerChoice, + ) + tags: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=7, + ) + order: int = proto.Field( + proto.INT32, + number=8, + ) + metrics: Metrics = proto.Field( + proto.MESSAGE, + number=10, + message=Metrics, + ) + tuning_metadata: TuningMetadata = proto.Field( + proto.MESSAGE, + number=11, + message=TuningMetadata, + ) + + +class QaScorecard(proto.Message): + r"""A QaScorecard represents a collection of questions to be + scored during analysis. + + Attributes: + name (str): + Identifier. The scorecard name. Format: + projects/{project}/locations/{location}/qaScorecards/{qa_scorecard} + display_name (str): + The user-specified display name of the + scorecard. + description (str): + A text description explaining the intent of + the scorecard. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this scorecard + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the scorecard was updated. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + display_name: str = proto.Field( + proto.STRING, + number=7, + ) + description: str = proto.Field( + proto.STRING, + number=2, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + + +class QaScorecardRevision(proto.Message): + r"""A revision of a QaScorecard. + + Modifying published scorecard fields would invalidate existing + scorecard results — the questions may have changed, or the score + weighting will make existing scores impossible to understand. So + changes must create a new revision, rather than modifying the + existing resource. + + Attributes: + name (str): + Identifier. The name of the scorecard revision. Format: + projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}/revisions/{revision} + snapshot (google.cloud.contact_center_insights_v1.types.QaScorecard): + The snapshot of the scorecard at the time of + this revision's creation. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp that the revision + was created. + alternate_ids (MutableSequence[str]): + Output only. Alternative IDs for this revision of the + scorecard, e.g., ``latest``. + state (google.cloud.contact_center_insights_v1.types.QaScorecardRevision.State): + Output only. State of the scorecard revision, + indicating whether it's ready to be used in + analysis. + """ + + class State(proto.Enum): + r"""Enum representing the set of states a scorecard revision may + be in. + + Values: + STATE_UNSPECIFIED (0): + Unspecified. + EDITABLE (12): + The scorecard revision can be edited. + TRAINING (2): + Scorecard model training is in progress. + TRAINING_FAILED (9): + Scorecard revision model training failed. + READY (11): + The revision can be used in analysis. + DELETING (7): + Scorecard is being deleted. + TRAINING_CANCELLED (14): + Scorecard model training was explicitly + cancelled by the user. + """ + STATE_UNSPECIFIED = 0 + EDITABLE = 12 + TRAINING = 2 + TRAINING_FAILED = 9 + READY = 11 + DELETING = 7 + TRAINING_CANCELLED = 14 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + snapshot: "QaScorecard" = proto.Field( + proto.MESSAGE, + number=2, + message="QaScorecard", + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + alternate_ids: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + state: State = proto.Field( + proto.ENUM, + number=5, + enum=State, + ) + + +class QaAnswer(proto.Message): + r"""An answer to a QaQuestion. + + Attributes: + qa_question (str): + The QaQuestion answered by this answer. + conversation (str): + The conversation the answer applies to. + question_body (str): + Question text. E.g., "Did the agent greet the + customer?". + answer_value (google.cloud.contact_center_insights_v1.types.QaAnswer.AnswerValue): + The main answer value, incorporating any + manual edits if they exist. + tags (MutableSequence[str]): + User-defined list of arbitrary tags. Matches + the value from + QaScorecard.ScorecardQuestion.tags. Used for + grouping/organization and for weighting the + score of each answer. + answer_sources (MutableSequence[google.cloud.contact_center_insights_v1.types.QaAnswer.AnswerSource]): + List of all individual answers given to the + question. + """ + + class AnswerValue(proto.Message): + r"""Message for holding the value of a + [QaAnswer][google.cloud.contactcenterinsights.v1.QaAnswer]. + [QaQuestion.AnswerChoice][google.cloud.contactcenterinsights.v1.QaQuestion.AnswerChoice] + defines the possible answer values for a question. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + str_value (str): + String value. + + This field is a member of `oneof`_ ``value``. + num_value (float): + Numerical value. + + This field is a member of `oneof`_ ``value``. + bool_value (bool): + Boolean value. + + This field is a member of `oneof`_ ``value``. + na_value (bool): + A value of "Not Applicable (N/A)". Should only ever be + ``true``. + + This field is a member of `oneof`_ ``value``. + key (str): + A short string used as an identifier. Matches + the value used in QaQuestion.AnswerChoice.key. + score (float): + Output only. Numerical score of the answer. + + This field is a member of `oneof`_ ``_score``. + potential_score (float): + Output only. The maximum potential score of + the question. + + This field is a member of `oneof`_ ``_potential_score``. + normalized_score (float): + Output only. Normalized score of the questions. Calculated + as score / potential_score. + + This field is a member of `oneof`_ ``_normalized_score``. + """ + + str_value: str = proto.Field( + proto.STRING, + number=2, + oneof="value", + ) + num_value: float = proto.Field( + proto.DOUBLE, + number=3, + oneof="value", + ) + bool_value: bool = proto.Field( + proto.BOOL, + number=4, + oneof="value", + ) + na_value: bool = proto.Field( + proto.BOOL, + number=5, + oneof="value", + ) + key: str = proto.Field( + proto.STRING, + number=1, + ) + score: float = proto.Field( + proto.DOUBLE, + number=6, + optional=True, + ) + potential_score: float = proto.Field( + proto.DOUBLE, + number=7, + optional=True, + ) + normalized_score: float = proto.Field( + proto.DOUBLE, + number=8, + optional=True, + ) + + class AnswerSource(proto.Message): + r"""A question may have multiple answers from varying sources, + one of which becomes the "main" answer above. AnswerSource + represents each individual answer. + + Attributes: + source_type (google.cloud.contact_center_insights_v1.types.QaAnswer.AnswerSource.SourceType): + What created the answer. + answer_value (google.cloud.contact_center_insights_v1.types.QaAnswer.AnswerValue): + The answer value from this source. + """ + + class SourceType(proto.Enum): + r"""What created the answer. + + Values: + SOURCE_TYPE_UNSPECIFIED (0): + Source type is unspecified. + SYSTEM_GENERATED (1): + Answer was system-generated; created during + an Insights analysis. + MANUAL_EDIT (2): + Answer was created by a human via manual + edit. + """ + SOURCE_TYPE_UNSPECIFIED = 0 + SYSTEM_GENERATED = 1 + MANUAL_EDIT = 2 + + source_type: "QaAnswer.AnswerSource.SourceType" = proto.Field( + proto.ENUM, + number=1, + enum="QaAnswer.AnswerSource.SourceType", + ) + answer_value: "QaAnswer.AnswerValue" = proto.Field( + proto.MESSAGE, + number=2, + message="QaAnswer.AnswerValue", + ) + + qa_question: str = proto.Field( + proto.STRING, + number=7, + ) + conversation: str = proto.Field( + proto.STRING, + number=2, + ) + question_body: str = proto.Field( + proto.STRING, + number=6, + ) + answer_value: AnswerValue = proto.Field( + proto.MESSAGE, + number=3, + message=AnswerValue, + ) + tags: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=5, + ) + answer_sources: MutableSequence[AnswerSource] = proto.RepeatedField( + proto.MESSAGE, + number=8, + message=AnswerSource, + ) + + +class QaScorecardResult(proto.Message): + r"""The results of scoring a single conversation against a + QaScorecard. Contains a collection of QaAnswers and aggregate + score. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. The name of the scorecard result. Format: + projects/{project}/locations/{location}/qaScorecardResults/{qa_scorecard_result} + qa_scorecard_revision (str): + The QaScorecardRevision scored by this + result. + conversation (str): + The conversation scored by this result. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp that the revision + was created. + agent_id (str): + ID of the agent that handled the + conversation. + qa_answers (MutableSequence[google.cloud.contact_center_insights_v1.types.QaAnswer]): + Set of QaAnswers represented in the result. + score (float): + The overall numerical score of the result, + incorporating any manual edits if they exist. + + This field is a member of `oneof`_ ``_score``. + potential_score (float): + The maximum potential overall score of the scorecard. Any + questions answered using ``na_value`` are excluded from this + calculation. + + This field is a member of `oneof`_ ``_potential_score``. + normalized_score (float): + The normalized score, which is the score + divided by the potential score. Any manual edits + are included if they exist. + + This field is a member of `oneof`_ ``_normalized_score``. + qa_tag_results (MutableSequence[google.cloud.contact_center_insights_v1.types.QaScorecardResult.QaTagResult]): + Collection of tags and their scores. + score_sources (MutableSequence[google.cloud.contact_center_insights_v1.types.QaScorecardResult.ScoreSource]): + List of all individual score sets. + """ + + class QaTagResult(proto.Message): + r"""Tags and their corresponding results. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + tag (str): + The tag the score applies to. + score (float): + The score the tag applies to. + + This field is a member of `oneof`_ ``_score``. + potential_score (float): + The potential score the tag applies to. + + This field is a member of `oneof`_ ``_potential_score``. + normalized_score (float): + The normalized score the tag applies to. + + This field is a member of `oneof`_ ``_normalized_score``. + """ + + tag: str = proto.Field( + proto.STRING, + number=1, + ) + score: float = proto.Field( + proto.DOUBLE, + number=2, + optional=True, + ) + potential_score: float = proto.Field( + proto.DOUBLE, + number=3, + optional=True, + ) + normalized_score: float = proto.Field( + proto.DOUBLE, + number=4, + optional=True, + ) + + class ScoreSource(proto.Message): + r"""A scorecard result may have multiple sets of scores from + varying sources, one of which becomes the "main" answer above. A + ScoreSource represents each individual set of scores. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + source_type (google.cloud.contact_center_insights_v1.types.QaScorecardResult.ScoreSource.SourceType): + What created the score. + score (float): + The overall numerical score of the result. + + This field is a member of `oneof`_ ``_score``. + potential_score (float): + The maximum potential overall score of the scorecard. Any + questions answered using ``na_value`` are excluded from this + calculation. + + This field is a member of `oneof`_ ``_potential_score``. + normalized_score (float): + The normalized score, which is the score + divided by the potential score. + + This field is a member of `oneof`_ ``_normalized_score``. + qa_tag_results (MutableSequence[google.cloud.contact_center_insights_v1.types.QaScorecardResult.QaTagResult]): + Collection of tags and their scores. + """ + + class SourceType(proto.Enum): + r"""What created the score. + + Values: + SOURCE_TYPE_UNSPECIFIED (0): + Source type is unspecified. + SYSTEM_GENERATED_ONLY (1): + Score is derived only from system-generated + answers. + INCLUDES_MANUAL_EDITS (2): + Score is derived from both system-generated + answers, and includes any manual edits if they + exist. + """ + SOURCE_TYPE_UNSPECIFIED = 0 + SYSTEM_GENERATED_ONLY = 1 + INCLUDES_MANUAL_EDITS = 2 + + source_type: "QaScorecardResult.ScoreSource.SourceType" = proto.Field( + proto.ENUM, + number=1, + enum="QaScorecardResult.ScoreSource.SourceType", + ) + score: float = proto.Field( + proto.DOUBLE, + number=2, + optional=True, + ) + potential_score: float = proto.Field( + proto.DOUBLE, + number=3, + optional=True, + ) + normalized_score: float = proto.Field( + proto.DOUBLE, + number=4, + optional=True, + ) + qa_tag_results: MutableSequence[ + "QaScorecardResult.QaTagResult" + ] = proto.RepeatedField( + proto.MESSAGE, + number=5, + message="QaScorecardResult.QaTagResult", + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + qa_scorecard_revision: str = proto.Field( + proto.STRING, + number=2, + ) + conversation: str = proto.Field( + proto.STRING, + number=3, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + agent_id: str = proto.Field( + proto.STRING, + number=5, + ) + qa_answers: MutableSequence["QaAnswer"] = proto.RepeatedField( + proto.MESSAGE, + number=6, + message="QaAnswer", + ) + score: float = proto.Field( + proto.DOUBLE, + number=7, + optional=True, + ) + potential_score: float = proto.Field( + proto.DOUBLE, + number=8, + optional=True, + ) + normalized_score: float = proto.Field( + proto.DOUBLE, + number=9, + optional=True, + ) + qa_tag_results: MutableSequence[QaTagResult] = proto.RepeatedField( + proto.MESSAGE, + number=10, + message=QaTagResult, + ) + score_sources: MutableSequence[ScoreSource] = proto.RepeatedField( + proto.MESSAGE, + number=11, + message=ScoreSource, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_async.py new file mode 100644 index 000000000000..f5430fda87a3 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BulkDownloadFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkDownloadFeedbackLabels_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_bulk_download_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + gcs_destination = contact_center_insights_v1.GcsDestination() + gcs_destination.format_ = "JSON" + gcs_destination.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkDownloadFeedbackLabelsRequest( + gcs_destination=gcs_destination, + parent="parent_value", + ) + + # Make the request + operation = client.bulk_download_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkDownloadFeedbackLabels_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_sync.py new file mode 100644 index 000000000000..04f10baed5a3 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BulkDownloadFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkDownloadFeedbackLabels_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_bulk_download_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + gcs_destination = contact_center_insights_v1.GcsDestination() + gcs_destination.format_ = "JSON" + gcs_destination.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkDownloadFeedbackLabelsRequest( + gcs_destination=gcs_destination, + parent="parent_value", + ) + + # Make the request + operation = client.bulk_download_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkDownloadFeedbackLabels_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_async.py new file mode 100644 index 000000000000..91a377a51805 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BulkUploadFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkUploadFeedbackLabels_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_bulk_upload_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.format_ = "JSON" + gcs_source.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkUploadFeedbackLabelsRequest( + gcs_source=gcs_source, + parent="parent_value", + ) + + # Make the request + operation = client.bulk_upload_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkUploadFeedbackLabels_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_sync.py new file mode 100644 index 000000000000..93533ead3fbd --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BulkUploadFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkUploadFeedbackLabels_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_bulk_upload_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.format_ = "JSON" + gcs_source.object_uri = "object_uri_value" + + request = contact_center_insights_v1.BulkUploadFeedbackLabelsRequest( + gcs_source=gcs_source, + parent="parent_value", + ) + + # Make the request + operation = client.bulk_upload_feedback_labels(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkUploadFeedbackLabels_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_async.py new file mode 100644 index 000000000000..4d3269820f1c --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysisRule_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateAnalysisRuleRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_analysis_rule(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysisRule_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_sync.py new file mode 100644 index 000000000000..2a7ec1925b03 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysisRule_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateAnalysisRuleRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_analysis_rule(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysisRule_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_async.py new file mode 100644 index 000000000000..aeb38500963c --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateFeedbackLabel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.CreateFeedbackLabelRequest( + parent="parent_value", + feedback_label=feedback_label, + ) + + # Make the request + response = await client.create_feedback_label(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateFeedbackLabel_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_sync.py new file mode 100644 index 000000000000..d98bc2658aad --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateFeedbackLabel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.CreateFeedbackLabelRequest( + parent="parent_value", + feedback_label=feedback_label, + ) + + # Make the request + response = client.create_feedback_label(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateFeedbackLabel_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_async.py new file mode 100644 index 000000000000..ea070f8e2c71 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaQuestion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaQuestionRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_qa_question(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaQuestion_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_sync.py new file mode 100644 index 000000000000..0ec4749da0c8 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaQuestion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaQuestionRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_qa_question(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaQuestion_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_async.py new file mode 100644 index 000000000000..db88aa466aaf --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecard_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_qa_scorecard(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecard_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_async.py new file mode 100644 index 000000000000..7289e9089378 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecardRevision_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRevisionRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecardRevision_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_sync.py new file mode 100644 index 000000000000..9b728506ca5b --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecardRevision_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRevisionRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecardRevision_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_sync.py new file mode 100644 index 000000000000..fa5a6a4dd380 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecard_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateQaScorecardRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_qa_scorecard(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecard_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_async.py new file mode 100644 index 000000000000..01ac8045163b --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysisRule_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteAnalysisRuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_analysis_rule(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysisRule_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_sync.py new file mode 100644 index 000000000000..39d5596ae7d9 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysisRule_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteAnalysisRuleRequest( + name="name_value", + ) + + # Make the request + client.delete_analysis_rule(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysisRule_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_async.py new file mode 100644 index 000000000000..4aa548a2bd96 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteFeedbackLabel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + await client.delete_feedback_label(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteFeedbackLabel_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_sync.py new file mode 100644 index 000000000000..0c6e265932ac --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteFeedbackLabel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + client.delete_feedback_label(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteFeedbackLabel_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_async.py new file mode 100644 index 000000000000..97239fff3128 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaQuestion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaQuestionRequest( + name="name_value", + ) + + # Make the request + await client.delete_qa_question(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaQuestion_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_sync.py new file mode 100644 index 000000000000..b8345f76e46d --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaQuestion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaQuestionRequest( + name="name_value", + ) + + # Make the request + client.delete_qa_question(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaQuestion_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_async.py new file mode 100644 index 000000000000..48ed25060a85 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecard_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRequest( + name="name_value", + ) + + # Make the request + await client.delete_qa_scorecard(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecard_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_async.py new file mode 100644 index 000000000000..8a3d83b5074f --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecardRevision_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + await client.delete_qa_scorecard_revision(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecardRevision_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_sync.py new file mode 100644 index 000000000000..7c47cf17bbc3 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecardRevision_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + client.delete_qa_scorecard_revision(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecardRevision_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_sync.py new file mode 100644 index 000000000000..a486e0322ef4 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecard_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteQaScorecardRequest( + name="name_value", + ) + + # Make the request + client.delete_qa_scorecard(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecard_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_async.py new file mode 100644 index 000000000000..f183cc9daa4d --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeployQaScorecardRevision_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_deploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.deploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeployQaScorecardRevision_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_sync.py new file mode 100644 index 000000000000..e66e81e600e6 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeployQaScorecardRevision_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_deploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.deploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeployQaScorecardRevision_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_async.py new file mode 100644 index 000000000000..1661dc5d4a6d --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysisRule_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetAnalysisRuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_analysis_rule(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysisRule_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_sync.py new file mode 100644 index 000000000000..06b63b19514d --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysisRule_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetAnalysisRuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_analysis_rule(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysisRule_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_async.py new file mode 100644 index 000000000000..a7592fab3d0a --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetFeedbackLabel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + response = await client.get_feedback_label(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetFeedbackLabel_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_sync.py new file mode 100644 index 000000000000..1d045fa13018 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetFeedbackLabel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetFeedbackLabelRequest( + name="name_value", + ) + + # Make the request + response = client.get_feedback_label(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetFeedbackLabel_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_async.py new file mode 100644 index 000000000000..0673448136d5 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetQaQuestion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaQuestionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_qa_question(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetQaQuestion_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_sync.py new file mode 100644 index 000000000000..961e94e8a065 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetQaQuestion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaQuestionRequest( + name="name_value", + ) + + # Make the request + response = client.get_qa_question(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetQaQuestion_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_async.py new file mode 100644 index 000000000000..df222ea1a19a --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecard_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRequest( + name="name_value", + ) + + # Make the request + response = await client.get_qa_scorecard(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecard_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_async.py new file mode 100644 index 000000000000..9dc66beb12db --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecardRevision_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecardRevision_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_sync.py new file mode 100644 index 000000000000..004d20bf5325 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecardRevision_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.get_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecardRevision_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_sync.py new file mode 100644 index 000000000000..931879b823a2 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecard_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetQaScorecardRequest( + name="name_value", + ) + + # Make the request + response = client.get_qa_scorecard(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecard_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_async.py new file mode 100644 index 000000000000..5cdd181cb9dd --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAllFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAllFeedbackLabels_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_all_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAllFeedbackLabelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_all_feedback_labels(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAllFeedbackLabels_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_sync.py new file mode 100644 index 000000000000..0ecdb2593035 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAllFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAllFeedbackLabels_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_all_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAllFeedbackLabelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_all_feedback_labels(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAllFeedbackLabels_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_async.py new file mode 100644 index 000000000000..3c88dbe291f8 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAnalysisRules +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalysisRules_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_analysis_rules(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAnalysisRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_analysis_rules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalysisRules_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_sync.py new file mode 100644 index 000000000000..7252a93b3049 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAnalysisRules +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalysisRules_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_analysis_rules(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAnalysisRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_analysis_rules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalysisRules_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_async.py new file mode 100644 index 000000000000..6160ce0367bd --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListFeedbackLabels_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListFeedbackLabelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_feedback_labels(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListFeedbackLabels_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_sync.py new file mode 100644 index 000000000000..16b3ff41e1f1 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFeedbackLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListFeedbackLabels_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_feedback_labels(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListFeedbackLabelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_feedback_labels(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListFeedbackLabels_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_async.py new file mode 100644 index 000000000000..76910da72293 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQaQuestions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListQaQuestions_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_qa_questions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaQuestionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_questions(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListQaQuestions_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_sync.py new file mode 100644 index 000000000000..084a7ce49301 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQaQuestions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListQaQuestions_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_qa_questions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaQuestionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_questions(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListQaQuestions_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_async.py new file mode 100644 index 000000000000..66a85563bab6 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQaScorecardRevisions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecardRevisions_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_qa_scorecard_revisions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecard_revisions(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecardRevisions_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_sync.py new file mode 100644 index 000000000000..c801bc135c46 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQaScorecardRevisions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecardRevisions_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_qa_scorecard_revisions(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecard_revisions(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecardRevisions_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_async.py new file mode 100644 index 000000000000..ec4ef4ea67e8 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQaScorecards +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecards_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_qa_scorecards(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecards(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecards_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_sync.py new file mode 100644 index 000000000000..0467b9be36cc --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQaScorecards +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecards_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_qa_scorecards(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListQaScorecardsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_qa_scorecards(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecards_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_query_metrics_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_query_metrics_async.py new file mode 100644 index 000000000000..f6ab4388417c --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_query_metrics_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for QueryMetrics +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_QueryMetrics_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_query_metrics(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.QueryMetricsRequest( + location="location_value", + filter="filter_value", + ) + + # Make the request + operation = client.query_metrics(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_QueryMetrics_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_query_metrics_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_query_metrics_sync.py new file mode 100644 index 000000000000..c35b07edb50c --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_query_metrics_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for QueryMetrics +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_QueryMetrics_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_query_metrics(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.QueryMetricsRequest( + location="location_value", + filter="filter_value", + ) + + # Make the request + operation = client.query_metrics(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_QueryMetrics_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_async.py new file mode 100644 index 000000000000..bc45be04e930 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TuneQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_TuneQaScorecardRevision_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_tune_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.TuneQaScorecardRevisionRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + operation = client.tune_qa_scorecard_revision(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_TuneQaScorecardRevision_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_sync.py new file mode 100644 index 000000000000..44b25814aebe --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TuneQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_TuneQaScorecardRevision_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_tune_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.TuneQaScorecardRevisionRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + operation = client.tune_qa_scorecard_revision(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_TuneQaScorecardRevision_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_async.py new file mode 100644 index 000000000000..86a4d3b97e14 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UndeployQaScorecardRevision_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_undeploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.undeploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UndeployQaScorecardRevision_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_sync.py new file mode 100644 index 000000000000..324a884a4a34 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployQaScorecardRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UndeployQaScorecardRevision_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_undeploy_qa_scorecard_revision(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.undeploy_qa_scorecard_revision(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UndeployQaScorecardRevision_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_async.py new file mode 100644 index 000000000000..b53aa512a558 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateAnalysisRule_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateAnalysisRuleRequest( + ) + + # Make the request + response = await client.update_analysis_rule(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateAnalysisRule_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_sync.py new file mode 100644 index 000000000000..cbc4e8046c67 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAnalysisRule +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateAnalysisRule_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_analysis_rule(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateAnalysisRuleRequest( + ) + + # Make the request + response = client.update_analysis_rule(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateAnalysisRule_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_async.py new file mode 100644 index 000000000000..a0f9369ffa42 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateFeedbackLabel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.UpdateFeedbackLabelRequest( + feedback_label=feedback_label, + ) + + # Make the request + response = await client.update_feedback_label(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateFeedbackLabel_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_sync.py new file mode 100644 index 000000000000..fdd90c5cac3b --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFeedbackLabel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateFeedbackLabel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_feedback_label(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + feedback_label = contact_center_insights_v1.FeedbackLabel() + feedback_label.label = "label_value" + + request = contact_center_insights_v1.UpdateFeedbackLabelRequest( + feedback_label=feedback_label, + ) + + # Make the request + response = client.update_feedback_label(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateFeedbackLabel_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_async.py new file mode 100644 index 000000000000..29235a00638f --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaQuestion_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaQuestionRequest( + ) + + # Make the request + response = await client.update_qa_question(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaQuestion_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_sync.py new file mode 100644 index 000000000000..aaf0a5affbb4 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQaQuestion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaQuestion_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_qa_question(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaQuestionRequest( + ) + + # Make the request + response = client.update_qa_question(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaQuestion_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_async.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_async.py new file mode 100644 index 000000000000..daf61def8ac0 --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaScorecard_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaScorecardRequest( + ) + + # Make the request + response = await client.update_qa_scorecard(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaScorecard_async] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_sync.py b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_sync.py new file mode 100644 index 000000000000..ee1067e50c5c --- /dev/null +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQaScorecard +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaScorecard_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_qa_scorecard(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateQaScorecardRequest( + ) + + # Make the request + response = client.update_qa_scorecard(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaScorecard_sync] diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json b/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json index 90d789df11c2..5b85f0b7ea75 100644 --- a/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-contact-center-insights", - "version": "1.19.1" + "version": "0.1.0" }, "snippets": [ { @@ -365,22 +365,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_issue_model_stats", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.bulk_download_feedback_labels", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkDownloadFeedbackLabels", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CalculateIssueModelStats" + "shortName": "BulkDownloadFeedbackLabels" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" + "type": "google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest" }, { - "name": "issue_model", + "name": "parent", "type": "str" }, { @@ -396,22 +396,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", - "shortName": "calculate_issue_model_stats" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "bulk_download_feedback_labels" }, - "description": "Sample for CalculateIssueModelStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py", + "description": "Sample for BulkDownloadFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkDownloadFeedbackLabels_async", "segments": [ { - "end": 51, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 60, "start": 27, "type": "SHORT" }, @@ -421,22 +421,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_async.py" }, { "canonical": true, @@ -445,22 +445,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_issue_model_stats", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.bulk_download_feedback_labels", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkDownloadFeedbackLabels", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CalculateIssueModelStats" + "shortName": "BulkDownloadFeedbackLabels" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" + "type": "google.cloud.contact_center_insights_v1.types.BulkDownloadFeedbackLabelsRequest" }, { - "name": "issue_model", + "name": "parent", "type": "str" }, { @@ -476,22 +476,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", - "shortName": "calculate_issue_model_stats" + "resultType": "google.api_core.operation.Operation", + "shortName": "bulk_download_feedback_labels" }, - "description": "Sample for CalculateIssueModelStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py", + "description": "Sample for BulkDownloadFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkDownloadFeedbackLabels_sync", "segments": [ { - "end": 51, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 60, "start": 27, "type": "SHORT" }, @@ -501,22 +501,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_download_feedback_labels_sync.py" }, { "canonical": true, @@ -526,22 +526,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_stats", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.bulk_upload_feedback_labels", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkUploadFeedbackLabels", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CalculateStats" + "shortName": "BulkUploadFeedbackLabels" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" + "type": "google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsRequest" }, { - "name": "location", + "name": "parent", "type": "str" }, { @@ -557,22 +557,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", - "shortName": "calculate_stats" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "bulk_upload_feedback_labels" }, - "description": "Sample for CalculateStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py", + "description": "Sample for BulkUploadFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkUploadFeedbackLabels_async", "segments": [ { - "end": 51, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 60, "start": 27, "type": "SHORT" }, @@ -582,22 +582,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_async.py" }, { "canonical": true, @@ -606,22 +606,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_stats", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.bulk_upload_feedback_labels", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkUploadFeedbackLabels", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CalculateStats" + "shortName": "BulkUploadFeedbackLabels" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" + "type": "google.cloud.contact_center_insights_v1.types.BulkUploadFeedbackLabelsRequest" }, { - "name": "location", + "name": "parent", "type": "str" }, { @@ -637,22 +637,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", - "shortName": "calculate_stats" + "resultType": "google.api_core.operation.Operation", + "shortName": "bulk_upload_feedback_labels" }, - "description": "Sample for CalculateStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py", + "description": "Sample for BulkUploadFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkUploadFeedbackLabels_sync", "segments": [ { - "end": 51, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 60, "start": 27, "type": "SHORT" }, @@ -662,22 +662,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_upload_feedback_labels_sync.py" }, { "canonical": true, @@ -687,28 +687,24 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_analysis", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_issue_model_stats", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateAnalysis" + "shortName": "CalculateIssueModelStats" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" + "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" }, { - "name": "parent", + "name": "issue_model", "type": "str" }, - { - "name": "analysis", - "type": "google.cloud.contact_center_insights_v1.types.Analysis" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -722,22 +718,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_analysis" + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", + "shortName": "calculate_issue_model_stats" }, - "description": "Sample for CreateAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py", + "description": "Sample for CalculateIssueModelStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -752,17 +748,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py" }, { "canonical": true, @@ -771,28 +767,24 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_analysis", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_issue_model_stats", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateAnalysis" + "shortName": "CalculateIssueModelStats" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" + "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" }, { - "name": "parent", + "name": "issue_model", "type": "str" }, - { - "name": "analysis", - "type": "google.cloud.contact_center_insights_v1.types.Analysis" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -806,22 +798,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_analysis" + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", + "shortName": "calculate_issue_model_stats" }, - "description": "Sample for CreateAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py", + "description": "Sample for CalculateIssueModelStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -836,17 +828,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py" }, { "canonical": true, @@ -856,30 +848,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_stats", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateConversation" + "shortName": "CalculateStats" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" + "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" }, { - "name": "conversation_id", + "name": "location", "type": "str" }, { @@ -895,14 +879,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "create_conversation" + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", + "shortName": "calculate_stats" }, - "description": "Sample for CreateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py", + "description": "Sample for CalculateStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async", "segments": [ { "end": 51, @@ -935,7 +919,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py" }, { "canonical": true, @@ -944,30 +928,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_stats", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateConversation" + "shortName": "CalculateStats" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" + "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" }, { - "name": "conversation_id", + "name": "location", "type": "str" }, { @@ -983,14 +959,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "create_conversation" + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", + "shortName": "calculate_stats" }, - "description": "Sample for CreateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py", + "description": "Sample for CalculateStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync", "segments": [ { "end": 51, @@ -1023,7 +999,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py" }, { "canonical": true, @@ -1033,27 +1009,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_analysis_rule", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysisRule", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateIssueModel" + "shortName": "CreateAnalysisRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRuleRequest" }, { "name": "parent", "type": "str" }, { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + "name": "analysis_rule", + "type": "google.cloud.contact_center_insights_v1.types.AnalysisRule" }, { "name": "retry", @@ -1068,22 +1044,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.AnalysisRule", + "shortName": "create_analysis_rule" }, - "description": "Sample for CreateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py", + "description": "Sample for CreateAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysisRule_async", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -1098,17 +1074,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_async.py" }, { "canonical": true, @@ -1117,27 +1093,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_analysis_rule", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysisRule", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateIssueModel" + "shortName": "CreateAnalysisRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRuleRequest" }, { "name": "parent", "type": "str" }, { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + "name": "analysis_rule", + "type": "google.cloud.contact_center_insights_v1.types.AnalysisRule" }, { "name": "retry", @@ -1152,22 +1128,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.AnalysisRule", + "shortName": "create_analysis_rule" }, - "description": "Sample for CreateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py", + "description": "Sample for CreateAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysisRule_sync", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -1182,17 +1158,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_rule_sync.py" }, { "canonical": true, @@ -1202,27 +1178,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_analysis", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreatePhraseMatcher" + "shortName": "CreateAnalysis" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" }, { "name": "parent", "type": "str" }, { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + "name": "analysis", + "type": "google.cloud.contact_center_insights_v1.types.Analysis" }, { "name": "retry", @@ -1237,14 +1213,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "create_phrase_matcher" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_analysis" }, - "description": "Sample for CreatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py", + "description": "Sample for CreateAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async", "segments": [ { "end": 55, @@ -1262,13 +1238,13 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { "end": 52, - "start": 50, + "start": 46, "type": "REQUEST_EXECUTION" }, { @@ -1277,7 +1253,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py" }, { "canonical": true, @@ -1286,27 +1262,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_analysis", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreatePhraseMatcher" + "shortName": "CreateAnalysis" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" }, { "name": "parent", "type": "str" }, { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + "name": "analysis", + "type": "google.cloud.contact_center_insights_v1.types.Analysis" }, { "name": "retry", @@ -1321,14 +1297,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "create_phrase_matcher" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_analysis" }, - "description": "Sample for CreatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py", + "description": "Sample for CreateAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync", "segments": [ { "end": 55, @@ -1346,13 +1322,13 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { "end": 52, - "start": 50, + "start": 46, "type": "REQUEST_EXECUTION" }, { @@ -1361,7 +1337,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py" }, { "canonical": true, @@ -1371,27 +1347,31 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_view", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_conversation", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateView" + "shortName": "CreateConversation" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" }, { "name": "parent", "type": "str" }, { - "name": "view", - "type": "google.cloud.contact_center_insights_v1.types.View" + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "conversation_id", + "type": "str" }, { "name": "retry", @@ -1406,14 +1386,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "create_view" + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "create_conversation" }, - "description": "Sample for CreateView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py", + "description": "Sample for CreateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async", "segments": [ { "end": 51, @@ -1446,7 +1426,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py" }, { "canonical": true, @@ -1455,27 +1435,31 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_view", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_conversation", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "CreateView" + "shortName": "CreateConversation" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" }, { "name": "parent", "type": "str" }, { - "name": "view", - "type": "google.cloud.contact_center_insights_v1.types.View" + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "conversation_id", + "type": "str" }, { "name": "retry", @@ -1490,14 +1474,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "create_view" + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "create_conversation" }, - "description": "Sample for CreateView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py", + "description": "Sample for CreateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync", "segments": [ { "end": 51, @@ -1530,7 +1514,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py" }, { "canonical": true, @@ -1540,22 +1524,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_analysis", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_feedback_label", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateFeedbackLabel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteAnalysis" + "shortName": "CreateFeedbackLabel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateFeedbackLabelRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "feedback_label", + "type": "google.cloud.contact_center_insights_v1.types.FeedbackLabel" + }, + { + "name": "feedback_label_id", "type": "str" }, { @@ -1571,21 +1563,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_analysis" + "resultType": "google.cloud.contact_center_insights_v1.types.FeedbackLabel", + "shortName": "create_feedback_label" }, - "description": "Sample for DeleteAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py", + "description": "Sample for CreateFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateFeedbackLabel_async", "segments": [ { - "end": 49, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1595,20 +1588,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_async.py" }, { "canonical": true, @@ -1617,22 +1612,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_analysis", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_feedback_label", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateFeedbackLabel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteAnalysis" + "shortName": "CreateFeedbackLabel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateFeedbackLabelRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "feedback_label", + "type": "google.cloud.contact_center_insights_v1.types.FeedbackLabel" + }, + { + "name": "feedback_label_id", "type": "str" }, { @@ -1648,21 +1651,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_analysis" + "resultType": "google.cloud.contact_center_insights_v1.types.FeedbackLabel", + "shortName": "create_feedback_label" }, - "description": "Sample for DeleteAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py", + "description": "Sample for CreateFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateFeedbackLabel_sync", "segments": [ { - "end": 49, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1672,20 +1676,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_feedback_label_sync.py" }, { "canonical": true, @@ -1695,24 +1701,28 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteConversation" + "shortName": "CreateIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1726,21 +1736,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_conversation" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_issue_model" }, - "description": "Sample for DeleteConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py", + "description": "Sample for CreateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async", "segments": [ { - "end": 49, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1755,15 +1766,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py" }, { "canonical": true, @@ -1772,24 +1785,28 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteConversation" + "shortName": "CreateIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1803,21 +1820,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_conversation" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_issue_model" }, - "description": "Sample for DeleteConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py", + "description": "Sample for CreateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync", "segments": [ { - "end": 49, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1832,15 +1850,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py" }, { "canonical": true, @@ -1850,24 +1870,28 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_phrase_matcher", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteIssueModel" + "shortName": "CreatePhraseMatcher" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1881,14 +1905,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "create_phrase_matcher" }, - "description": "Sample for DeleteIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py", + "description": "Sample for CreatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async", "segments": [ { "end": 55, @@ -1906,13 +1930,13 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { "end": 52, - "start": 46, + "start": 50, "type": "REQUEST_EXECUTION" }, { @@ -1921,7 +1945,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py" }, { "canonical": true, @@ -1930,24 +1954,28 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_phrase_matcher", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteIssueModel" + "shortName": "CreatePhraseMatcher" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1961,14 +1989,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "create_phrase_matcher" }, - "description": "Sample for DeleteIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py", + "description": "Sample for CreatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync", "segments": [ { "end": 55, @@ -1986,13 +2014,13 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { "end": 52, - "start": 46, + "start": 50, "type": "REQUEST_EXECUTION" }, { @@ -2001,7 +2029,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py" }, { "canonical": true, @@ -2011,22 +2039,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_qa_question", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateQaQuestion", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteIssue" + "shortName": "CreateQaQuestion" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateQaQuestionRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "qa_question", + "type": "google.cloud.contact_center_insights_v1.types.QaQuestion" + }, + { + "name": "qa_question_id", "type": "str" }, { @@ -2042,21 +2078,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_issue" + "resultType": "google.cloud.contact_center_insights_v1.types.QaQuestion", + "shortName": "create_qa_question" }, - "description": "Sample for DeleteIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py", + "description": "Sample for CreateQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaQuestion_async", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2071,15 +2108,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_async.py" }, { "canonical": true, @@ -2088,22 +2127,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_qa_question", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateQaQuestion", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteIssue" + "shortName": "CreateQaQuestion" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateQaQuestionRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "qa_question", + "type": "google.cloud.contact_center_insights_v1.types.QaQuestion" + }, + { + "name": "qa_question_id", "type": "str" }, { @@ -2119,21 +2166,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_issue" + "resultType": "google.cloud.contact_center_insights_v1.types.QaQuestion", + "shortName": "create_qa_question" }, - "description": "Sample for DeleteIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py", + "description": "Sample for CreateQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaQuestion_sync", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2148,15 +2196,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_question_sync.py" }, { "canonical": true, @@ -2166,22 +2216,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeletePhraseMatcher" + "shortName": "CreateQaScorecardRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateQaScorecardRevisionRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "qa_scorecard_revision", + "type": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision" + }, + { + "name": "qa_scorecard_revision_id", "type": "str" }, { @@ -2197,21 +2255,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_phrase_matcher" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "create_qa_scorecard_revision" }, - "description": "Sample for DeletePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py", + "description": "Sample for CreateQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecardRevision_async", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2226,15 +2285,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_async.py" }, { "canonical": true, @@ -2243,22 +2304,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeletePhraseMatcher" + "shortName": "CreateQaScorecardRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateQaScorecardRevisionRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "qa_scorecard_revision", + "type": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision" + }, + { + "name": "qa_scorecard_revision_id", "type": "str" }, { @@ -2274,21 +2343,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_phrase_matcher" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "create_qa_scorecard_revision" }, - "description": "Sample for DeletePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py", + "description": "Sample for CreateQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecardRevision_sync", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2303,15 +2373,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_revision_sync.py" }, { "canonical": true, @@ -2321,22 +2393,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_view", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_qa_scorecard", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateQaScorecard", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteView" + "shortName": "CreateQaScorecard" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateQaScorecardRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "qa_scorecard", + "type": "google.cloud.contact_center_insights_v1.types.QaScorecard" + }, + { + "name": "qa_scorecard_id", "type": "str" }, { @@ -2352,21 +2432,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_view" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecard", + "shortName": "create_qa_scorecard" }, - "description": "Sample for DeleteView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py", + "description": "Sample for CreateQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecard_async", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2381,15 +2462,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_async.py" }, { "canonical": true, @@ -2398,22 +2481,30 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_view", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_qa_scorecard", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateQaScorecard", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeleteView" + "shortName": "CreateQaScorecard" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateQaScorecardRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "qa_scorecard", + "type": "google.cloud.contact_center_insights_v1.types.QaScorecard" + }, + { + "name": "qa_scorecard_id", "type": "str" }, { @@ -2429,21 +2520,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_view" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecard", + "shortName": "create_qa_scorecard" }, - "description": "Sample for DeleteView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py", + "description": "Sample for CreateQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateQaScorecard_sync", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2458,15 +2550,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_qa_scorecard_sync.py" }, { "canonical": true, @@ -2476,24 +2570,28 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.deploy_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_view", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeployIssueModel" + "shortName": "CreateView" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "view", + "type": "google.cloud.contact_center_insights_v1.types.View" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2507,22 +2605,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "deploy_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "create_view" }, - "description": "Sample for DeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py", + "description": "Sample for CreateView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2537,17 +2635,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py" }, { "canonical": true, @@ -2556,24 +2654,28 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.deploy_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_view", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "DeployIssueModel" + "shortName": "CreateView" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "view", + "type": "google.cloud.contact_center_insights_v1.types.View" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2587,22 +2689,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "deploy_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "create_view" }, - "description": "Sample for DeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py", + "description": "Sample for CreateView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2617,17 +2719,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py" }, { "canonical": true, @@ -2637,22 +2739,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.export_insights_data", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_analysis_rule", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysisRule", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ExportInsightsData" + "shortName": "DeleteAnalysisRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRuleRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -2668,22 +2770,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "export_insights_data" + "shortName": "delete_analysis_rule" }, - "description": "Sample for ExportInsightsData", - "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py", + "description": "Sample for DeleteAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysisRule_async", "segments": [ { - "end": 59, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 49, "start": 27, "type": "SHORT" }, @@ -2693,22 +2794,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 50, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_async.py" }, { "canonical": true, @@ -2717,22 +2816,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.export_insights_data", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_analysis_rule", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysisRule", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ExportInsightsData" + "shortName": "DeleteAnalysisRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRuleRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -2748,22 +2847,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "export_insights_data" + "shortName": "delete_analysis_rule" }, - "description": "Sample for ExportInsightsData", - "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py", + "description": "Sample for DeleteAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysisRule_sync", "segments": [ { - "end": 59, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 49, "start": 27, "type": "SHORT" }, @@ -2773,22 +2871,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 50, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_rule_sync.py" }, { "canonical": true, @@ -2798,19 +2894,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.export_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_analysis", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ExportIssueModel" + "shortName": "DeleteAnalysis" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ExportIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" }, { "name": "name", @@ -2829,22 +2925,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "export_issue_model" + "shortName": "delete_analysis" }, - "description": "Sample for ExportIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_async.py", + "description": "Sample for DeleteAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async", "segments": [ { - "end": 59, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 49, "start": 27, "type": "SHORT" }, @@ -2854,22 +2949,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 50, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py" }, { "canonical": true, @@ -2878,19 +2971,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.export_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_analysis", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ExportIssueModel" + "shortName": "DeleteAnalysis" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ExportIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" }, { "name": "name", @@ -2909,22 +3002,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "export_issue_model" + "shortName": "delete_analysis" }, - "description": "Sample for ExportIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_sync.py", + "description": "Sample for DeleteAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync", "segments": [ { - "end": 59, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 49, "start": 27, "type": "SHORT" }, @@ -2934,22 +3026,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 50, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py" }, { "canonical": true, @@ -2959,19 +3049,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_analysis", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_conversation", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetAnalysis" + "shortName": "DeleteConversation" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" }, { "name": "name", @@ -2990,22 +3080,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", - "shortName": "get_analysis" + "shortName": "delete_conversation" }, - "description": "Sample for GetAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py", + "description": "Sample for DeleteConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3020,17 +3109,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py" }, { "canonical": true, @@ -3039,19 +3126,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_analysis", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_conversation", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetAnalysis" + "shortName": "DeleteConversation" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" }, { "name": "name", @@ -3070,22 +3157,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", - "shortName": "get_analysis" + "shortName": "delete_conversation" }, - "description": "Sample for GetAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py", + "description": "Sample for DeleteConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3100,17 +3186,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py" }, { "canonical": true, @@ -3120,19 +3204,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_feedback_label", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteFeedbackLabel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetConversation" + "shortName": "DeleteFeedbackLabel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteFeedbackLabelRequest" }, { "name": "name", @@ -3151,22 +3235,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "get_conversation" + "shortName": "delete_feedback_label" }, - "description": "Sample for GetConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py", + "description": "Sample for DeleteFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteFeedbackLabel_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3181,17 +3264,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_async.py" }, { "canonical": true, @@ -3200,19 +3281,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_feedback_label", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteFeedbackLabel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetConversation" + "shortName": "DeleteFeedbackLabel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteFeedbackLabelRequest" }, { "name": "name", @@ -3231,22 +3312,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "get_conversation" + "shortName": "delete_feedback_label" }, - "description": "Sample for GetConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py", + "description": "Sample for DeleteFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteFeedbackLabel_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3261,17 +3341,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_feedback_label_sync.py" }, { "canonical": true, @@ -3281,19 +3359,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_encryption_spec", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetEncryptionSpec", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetEncryptionSpec" + "shortName": "DeleteIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" }, { "name": "name", @@ -3312,22 +3390,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.EncryptionSpec", - "shortName": "get_encryption_spec" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_issue_model" }, - "description": "Sample for GetEncryptionSpec", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_async.py", + "description": "Sample for DeleteIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetEncryptionSpec_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3342,17 +3420,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py" }, { "canonical": true, @@ -3361,19 +3439,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_encryption_spec", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetEncryptionSpec", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetEncryptionSpec" + "shortName": "DeleteIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" }, { "name": "name", @@ -3392,22 +3470,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.EncryptionSpec", - "shortName": "get_encryption_spec" + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_issue_model" }, - "description": "Sample for GetEncryptionSpec", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_sync.py", + "description": "Sample for DeleteIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetEncryptionSpec_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3422,17 +3500,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py" }, { "canonical": true, @@ -3442,19 +3520,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetIssueModel" + "shortName": "DeleteIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" }, { "name": "name", @@ -3473,22 +3551,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "get_issue_model" + "shortName": "delete_issue" }, - "description": "Sample for GetIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py", + "description": "Sample for DeleteIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3503,17 +3580,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py" }, { "canonical": true, @@ -3522,19 +3597,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetIssueModel" + "shortName": "DeleteIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" }, { "name": "name", @@ -3553,22 +3628,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "get_issue_model" + "shortName": "delete_issue" }, - "description": "Sample for GetIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py", + "description": "Sample for DeleteIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3583,17 +3657,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py" }, { "canonical": true, @@ -3603,19 +3675,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_phrase_matcher", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetIssue" + "shortName": "DeletePhraseMatcher" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" }, { "name": "name", @@ -3634,22 +3706,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "get_issue" + "shortName": "delete_phrase_matcher" }, - "description": "Sample for GetIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py", + "description": "Sample for DeletePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3664,17 +3735,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py" }, { "canonical": true, @@ -3683,19 +3752,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_phrase_matcher", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetIssue" + "shortName": "DeletePhraseMatcher" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" }, { "name": "name", @@ -3714,22 +3783,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "get_issue" + "shortName": "delete_phrase_matcher" }, - "description": "Sample for GetIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py", + "description": "Sample for DeletePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3744,17 +3812,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py" }, { "canonical": true, @@ -3764,19 +3830,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_qa_question", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteQaQuestion", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetPhraseMatcher" + "shortName": "DeleteQaQuestion" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteQaQuestionRequest" }, { "name": "name", @@ -3795,22 +3861,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "get_phrase_matcher" + "shortName": "delete_qa_question" }, - "description": "Sample for GetPhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py", + "description": "Sample for DeleteQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaQuestion_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3825,17 +3890,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_async.py" }, { "canonical": true, @@ -3844,19 +3907,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_qa_question", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteQaQuestion", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetPhraseMatcher" + "shortName": "DeleteQaQuestion" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteQaQuestionRequest" }, { "name": "name", @@ -3875,22 +3938,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "get_phrase_matcher" + "shortName": "delete_qa_question" }, - "description": "Sample for GetPhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py", + "description": "Sample for DeleteQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaQuestion_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3905,17 +3967,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_question_sync.py" }, { "canonical": true, @@ -3925,19 +3985,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_settings", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetSettings" + "shortName": "DeleteQaScorecardRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRevisionRequest" }, { "name": "name", @@ -3956,22 +4016,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Settings", - "shortName": "get_settings" + "shortName": "delete_qa_scorecard_revision" }, - "description": "Sample for GetSettings", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py", + "description": "Sample for DeleteQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecardRevision_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3986,17 +4045,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_async.py" }, { "canonical": true, @@ -4005,19 +4062,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_settings", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetSettings" + "shortName": "DeleteQaScorecardRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRevisionRequest" }, { "name": "name", @@ -4036,22 +4093,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Settings", - "shortName": "get_settings" + "shortName": "delete_qa_scorecard_revision" }, - "description": "Sample for GetSettings", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py", + "description": "Sample for DeleteQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecardRevision_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -4066,17 +4122,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_revision_sync.py" }, { "canonical": true, @@ -4086,19 +4140,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_view", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_qa_scorecard", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteQaScorecard", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetView" + "shortName": "DeleteQaScorecard" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRequest" }, { "name": "name", @@ -4117,22 +4171,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "get_view" + "shortName": "delete_qa_scorecard" }, - "description": "Sample for GetView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py", + "description": "Sample for DeleteQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecard_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -4147,17 +4200,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_async.py" }, { "canonical": true, @@ -4166,19 +4217,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_view", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_qa_scorecard", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteQaScorecard", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "GetView" + "shortName": "DeleteQaScorecard" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteQaScorecardRequest" }, { "name": "name", @@ -4197,22 +4248,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "get_view" + "shortName": "delete_qa_scorecard" }, - "description": "Sample for GetView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py", + "description": "Sample for DeleteQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteQaScorecard_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -4227,17 +4277,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_qa_scorecard_sync.py" }, { "canonical": true, @@ -4247,22 +4295,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.import_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_view", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ImportIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ImportIssueModel" + "shortName": "DeleteView" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ImportIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -4278,22 +4326,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "import_issue_model" + "shortName": "delete_view" }, - "description": "Sample for ImportIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_async.py", + "description": "Sample for DeleteView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ImportIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async", "segments": [ { - "end": 59, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 49, "start": 27, "type": "SHORT" }, @@ -4302,23 +4349,179 @@ "start": 38, "type": "CLIENT_INITIALIZATION" }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_view" + }, + "description": "Sample for DeleteView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, { "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 50, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.deploy_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeployIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "deploy_issue_model" + }, + "description": "Sample for DeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py" }, { "canonical": true, @@ -4327,22 +4530,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.import_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.deploy_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ImportIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ImportIssueModel" + "shortName": "DeployIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ImportIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -4359,21 +4562,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "import_issue_model" + "shortName": "deploy_issue_model" }, - "description": "Sample for ImportIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_sync.py", + "description": "Sample for DeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ImportIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync", "segments": [ { - "end": 59, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 55, "start": 27, "type": "SHORT" }, @@ -4383,22 +4586,4844 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, { "end": 56, - "start": 50, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.deploy_qa_scorecard_revision", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployQaScorecardRevision", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeployQaScorecardRevision" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeployQaScorecardRevisionRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "deploy_qa_scorecard_revision" + }, + "description": "Sample for DeployQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployQaScorecardRevision_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.deploy_qa_scorecard_revision", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployQaScorecardRevision", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeployQaScorecardRevision" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeployQaScorecardRevisionRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "deploy_qa_scorecard_revision" + }, + "description": "Sample for DeployQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployQaScorecardRevision_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_qa_scorecard_revision_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.export_insights_data", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ExportInsightsData" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "export_insights_data" + }, + "description": "Sample for ExportInsightsData", + "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.export_insights_data", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ExportInsightsData" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "export_insights_data" + }, + "description": "Sample for ExportInsightsData", + "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.export_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ExportIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ExportIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "export_issue_model" + }, + "description": "Sample for ExportIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportIssueModel_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.export_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ExportIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ExportIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "export_issue_model" + }, + "description": "Sample for ExportIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportIssueModel_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_export_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_analysis_rule", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysisRule", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetAnalysisRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.AnalysisRule", + "shortName": "get_analysis_rule" + }, + "description": "Sample for GetAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysisRule_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_analysis_rule", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysisRule", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetAnalysisRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.AnalysisRule", + "shortName": "get_analysis_rule" + }, + "description": "Sample for GetAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysisRule_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", + "shortName": "get_analysis" + }, + "description": "Sample for GetAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", + "shortName": "get_analysis" + }, + "description": "Sample for GetAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "get_conversation" + }, + "description": "Sample for GetConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "get_conversation" + }, + "description": "Sample for GetConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_encryption_spec", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetEncryptionSpec", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetEncryptionSpec" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.EncryptionSpec", + "shortName": "get_encryption_spec" + }, + "description": "Sample for GetEncryptionSpec", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetEncryptionSpec_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_encryption_spec", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetEncryptionSpec", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetEncryptionSpec" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetEncryptionSpecRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.EncryptionSpec", + "shortName": "get_encryption_spec" + }, + "description": "Sample for GetEncryptionSpec", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetEncryptionSpec_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_encryption_spec_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_feedback_label", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetFeedbackLabel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetFeedbackLabel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetFeedbackLabelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.FeedbackLabel", + "shortName": "get_feedback_label" + }, + "description": "Sample for GetFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetFeedbackLabel_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_feedback_label", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetFeedbackLabel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetFeedbackLabel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetFeedbackLabelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.FeedbackLabel", + "shortName": "get_feedback_label" + }, + "description": "Sample for GetFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetFeedbackLabel_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_feedback_label_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "get_issue_model" + }, + "description": "Sample for GetIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "get_issue_model" + }, + "description": "Sample for GetIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "get_issue" + }, + "description": "Sample for GetIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "get_issue" + }, + "description": "Sample for GetIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetPhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "get_phrase_matcher" + }, + "description": "Sample for GetPhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetPhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "get_phrase_matcher" + }, + "description": "Sample for GetPhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_qa_question", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetQaQuestion", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetQaQuestion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetQaQuestionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaQuestion", + "shortName": "get_qa_question" + }, + "description": "Sample for GetQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetQaQuestion_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_qa_question", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetQaQuestion", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetQaQuestion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetQaQuestionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaQuestion", + "shortName": "get_qa_question" + }, + "description": "Sample for GetQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetQaQuestion_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_question_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_qa_scorecard_revision", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetQaScorecardRevision", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetQaScorecardRevision" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetQaScorecardRevisionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "get_qa_scorecard_revision" + }, + "description": "Sample for GetQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecardRevision_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_qa_scorecard_revision", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetQaScorecardRevision", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetQaScorecardRevision" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetQaScorecardRevisionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "get_qa_scorecard_revision" + }, + "description": "Sample for GetQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecardRevision_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_revision_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_qa_scorecard", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetQaScorecard", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetQaScorecard" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetQaScorecardRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecard", + "shortName": "get_qa_scorecard" + }, + "description": "Sample for GetQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecard_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_qa_scorecard", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetQaScorecard", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetQaScorecard" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetQaScorecardRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecard", + "shortName": "get_qa_scorecard" + }, + "description": "Sample for GetQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetQaScorecard_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_qa_scorecard_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_settings", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Settings", + "shortName": "get_settings" + }, + "description": "Sample for GetSettings", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_settings", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Settings", + "shortName": "get_settings" + }, + "description": "Sample for GetSettings", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "get_view" + }, + "description": "Sample for GetView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "get_view" + }, + "description": "Sample for GetView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.import_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ImportIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ImportIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ImportIssueModelRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "import_issue_model" + }, + "description": "Sample for ImportIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ImportIssueModel_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.import_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ImportIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ImportIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ImportIssueModelRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "import_issue_model" + }, + "description": "Sample for ImportIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ImportIssueModel_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.ingest_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "IngestConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "ingest_conversations" + }, + "description": "Sample for IngestConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async", + "segments": [ + { + "end": 63, + "start": 27, + "type": "FULL" + }, + { + "end": 63, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 60, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 64, + "start": 61, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.ingest_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "IngestConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "ingest_conversations" + }, + "description": "Sample for IngestConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync", + "segments": [ + { + "end": 63, + "start": 27, + "type": "FULL" + }, + { + "end": 63, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 60, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 64, + "start": 61, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.initialize_encryption_spec", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.InitializeEncryptionSpec", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "InitializeEncryptionSpec" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest" + }, + { + "name": "encryption_spec", + "type": "google.cloud.contact_center_insights_v1.types.EncryptionSpec" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "initialize_encryption_spec" + }, + "description": "Sample for InitializeEncryptionSpec", + "file": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_InitializeEncryptionSpec_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.initialize_encryption_spec", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.InitializeEncryptionSpec", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "InitializeEncryptionSpec" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest" + }, + { + "name": "encryption_spec", + "type": "google.cloud.contact_center_insights_v1.types.EncryptionSpec" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "initialize_encryption_spec" + }, + "description": "Sample for InitializeEncryptionSpec", + "file": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_InitializeEncryptionSpec_sync", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_all_feedback_labels", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAllFeedbackLabels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAllFeedbackLabels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAllFeedbackLabelsAsyncPager", + "shortName": "list_all_feedback_labels" + }, + "description": "Sample for ListAllFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAllFeedbackLabels_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_all_feedback_labels", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAllFeedbackLabels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAllFeedbackLabels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAllFeedbackLabelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAllFeedbackLabelsPager", + "shortName": "list_all_feedback_labels" + }, + "description": "Sample for ListAllFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAllFeedbackLabels_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_all_feedback_labels_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_analyses", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAnalyses" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesAsyncPager", + "shortName": "list_analyses" + }, + "description": "Sample for ListAnalyses", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_analyses", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAnalyses" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesPager", + "shortName": "list_analyses" + }, + "description": "Sample for ListAnalyses", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_analysis_rules", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalysisRules", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAnalysisRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAnalysisRulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysisRulesAsyncPager", + "shortName": "list_analysis_rules" + }, + "description": "Sample for ListAnalysisRules", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalysisRules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_analysis_rules", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalysisRules", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAnalysisRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAnalysisRulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysisRulesPager", + "shortName": "list_analysis_rules" + }, + "description": "Sample for ListAnalysisRules", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalysisRules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analysis_rules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsAsyncPager", + "shortName": "list_conversations" + }, + "description": "Sample for ListConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsPager", + "shortName": "list_conversations" + }, + "description": "Sample for ListConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_feedback_labels", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListFeedbackLabels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListFeedbackLabels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListFeedbackLabelsAsyncPager", + "shortName": "list_feedback_labels" + }, + "description": "Sample for ListFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListFeedbackLabels_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_feedback_labels", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListFeedbackLabels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListFeedbackLabels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListFeedbackLabelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListFeedbackLabelsPager", + "shortName": "list_feedback_labels" + }, + "description": "Sample for ListFeedbackLabels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListFeedbackLabels_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_feedback_labels_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issue_models", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssueModels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", + "shortName": "list_issue_models" + }, + "description": "Sample for ListIssueModels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issue_models", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssueModels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", + "shortName": "list_issue_models" + }, + "description": "Sample for ListIssueModels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issues", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", + "shortName": "list_issues" + }, + "description": "Sample for ListIssues", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issues", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", + "shortName": "list_issues" + }, + "description": "Sample for ListIssues", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_phrase_matchers", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListPhraseMatchers" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersAsyncPager", + "shortName": "list_phrase_matchers" + }, + "description": "Sample for ListPhraseMatchers", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_phrase_matchers", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListPhraseMatchers" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersPager", + "shortName": "list_phrase_matchers" + }, + "description": "Sample for ListPhraseMatchers", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_qa_questions", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListQaQuestions", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListQaQuestions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListQaQuestionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaQuestionsAsyncPager", + "shortName": "list_qa_questions" + }, + "description": "Sample for ListQaQuestions", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListQaQuestions_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_qa_questions", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListQaQuestions", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListQaQuestions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListQaQuestionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaQuestionsPager", + "shortName": "list_qa_questions" + }, + "description": "Sample for ListQaQuestions", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListQaQuestions_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_questions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_qa_scorecard_revisions", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListQaScorecardRevisions", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListQaScorecardRevisions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardRevisionsAsyncPager", + "shortName": "list_qa_scorecard_revisions" + }, + "description": "Sample for ListQaScorecardRevisions", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecardRevisions_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_qa_scorecard_revisions", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListQaScorecardRevisions", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListQaScorecardRevisions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListQaScorecardRevisionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardRevisionsPager", + "shortName": "list_qa_scorecard_revisions" + }, + "description": "Sample for ListQaScorecardRevisions", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecardRevisions_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecard_revisions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_qa_scorecards", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListQaScorecards", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListQaScorecards" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListQaScorecardsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardsAsyncPager", + "shortName": "list_qa_scorecards" + }, + "description": "Sample for ListQaScorecards", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecards_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_qa_scorecards", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListQaScorecards", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListQaScorecards" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListQaScorecardsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListQaScorecardsPager", + "shortName": "list_qa_scorecards" + }, + "description": "Sample for ListQaScorecards", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListQaScorecards_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_import_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_qa_scorecards_sync.py" }, { "canonical": true, @@ -4408,19 +9433,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.ingest_conversations", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_views", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "IngestConversations" + "shortName": "ListViews" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" + "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" }, { "name": "parent", @@ -4439,22 +9464,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "ingest_conversations" + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager", + "shortName": "list_views" }, - "description": "Sample for IngestConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py", + "description": "Sample for ListViews", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async", "segments": [ { - "end": 63, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 63, + "end": 52, "start": 27, "type": "SHORT" }, @@ -4464,22 +9489,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 53, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 60, - "start": 54, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 64, - "start": 61, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py" }, { "canonical": true, @@ -4488,19 +9513,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.ingest_conversations", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_views", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "IngestConversations" + "shortName": "ListViews" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" + "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" }, { "name": "parent", @@ -4519,22 +9544,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "ingest_conversations" + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager", + "shortName": "list_views" }, - "description": "Sample for IngestConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py", + "description": "Sample for ListViews", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync", "segments": [ { - "end": 63, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 63, + "end": 52, "start": 27, "type": "SHORT" }, @@ -4544,22 +9569,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 53, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 60, - "start": 54, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 64, - "start": 61, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py" }, { "canonical": true, @@ -4569,23 +9594,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.initialize_encryption_spec", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.query_metrics", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.InitializeEncryptionSpec", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.QueryMetrics", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "InitializeEncryptionSpec" + "shortName": "QueryMetrics" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest" - }, - { - "name": "encryption_spec", - "type": "google.cloud.contact_center_insights_v1.types.EncryptionSpec" + "type": "google.cloud.contact_center_insights_v1.types.QueryMetricsRequest" }, { "name": "retry", @@ -4601,21 +9622,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "initialize_encryption_spec" + "shortName": "query_metrics" }, - "description": "Sample for InitializeEncryptionSpec", - "file": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_async.py", + "description": "Sample for QueryMetrics", + "file": "contactcenterinsights_v1_generated_contact_center_insights_query_metrics_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_InitializeEncryptionSpec_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_QueryMetrics_async", "segments": [ { - "end": 58, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 58, + "end": 56, "start": 27, "type": "SHORT" }, @@ -4625,22 +9646,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 48, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 55, - "start": 49, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 59, - "start": 56, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_query_metrics_async.py" }, { "canonical": true, @@ -4649,23 +9670,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.initialize_encryption_spec", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.query_metrics", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.InitializeEncryptionSpec", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.QueryMetrics", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "InitializeEncryptionSpec" + "shortName": "QueryMetrics" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.InitializeEncryptionSpecRequest" - }, - { - "name": "encryption_spec", - "type": "google.cloud.contact_center_insights_v1.types.EncryptionSpec" + "type": "google.cloud.contact_center_insights_v1.types.QueryMetricsRequest" }, { "name": "retry", @@ -4681,21 +9698,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "initialize_encryption_spec" + "shortName": "query_metrics" }, - "description": "Sample for InitializeEncryptionSpec", - "file": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_sync.py", + "description": "Sample for QueryMetrics", + "file": "contactcenterinsights_v1_generated_contact_center_insights_query_metrics_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_InitializeEncryptionSpec_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_QueryMetrics_sync", "segments": [ { - "end": 58, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 58, + "end": 56, "start": 27, "type": "SHORT" }, @@ -4705,22 +9722,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 48, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 55, - "start": 49, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 59, - "start": 56, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_initialize_encryption_spec_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_query_metrics_sync.py" }, { "canonical": true, @@ -4730,24 +9747,32 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_analyses", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.tune_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.TuneQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListAnalyses" + "shortName": "TuneQaScorecardRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" + "type": "google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionRequest" }, { "name": "parent", "type": "str" }, + { + "name": "filter", + "type": "str" + }, + { + "name": "validate_only", + "type": "bool" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -4761,22 +9786,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesAsyncPager", - "shortName": "list_analyses" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "tune_qa_scorecard_revision" }, - "description": "Sample for ListAnalyses", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py", + "description": "Sample for TuneQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_TuneQaScorecardRevision_async", "segments": [ { - "end": 52, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 56, "start": 27, "type": "SHORT" }, @@ -4786,22 +9811,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_async.py" }, { "canonical": true, @@ -4810,24 +9835,32 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_analyses", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.tune_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.TuneQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListAnalyses" + "shortName": "TuneQaScorecardRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" + "type": "google.cloud.contact_center_insights_v1.types.TuneQaScorecardRevisionRequest" }, { "name": "parent", "type": "str" }, + { + "name": "filter", + "type": "str" + }, + { + "name": "validate_only", + "type": "bool" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -4841,22 +9874,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesPager", - "shortName": "list_analyses" + "resultType": "google.api_core.operation.Operation", + "shortName": "tune_qa_scorecard_revision" }, - "description": "Sample for ListAnalyses", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py", + "description": "Sample for TuneQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_TuneQaScorecardRevision_sync", "segments": [ { - "end": 52, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 56, "start": 27, "type": "SHORT" }, @@ -4866,22 +9899,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_tune_qa_scorecard_revision_sync.py" }, { "canonical": true, @@ -4891,22 +9924,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_conversations", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.undeploy_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListConversations" + "shortName": "UndeployIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" + "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -4922,22 +9955,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsAsyncPager", - "shortName": "list_conversations" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "undeploy_issue_model" }, - "description": "Sample for ListConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py", + "description": "Sample for UndeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async", "segments": [ { - "end": 52, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 55, "start": 27, "type": "SHORT" }, @@ -4952,17 +9985,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py" }, { "canonical": true, @@ -4971,22 +10004,22 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_conversations", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.undeploy_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListConversations" + "shortName": "UndeployIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" + "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -5002,22 +10035,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsPager", - "shortName": "list_conversations" + "resultType": "google.api_core.operation.Operation", + "shortName": "undeploy_issue_model" }, - "description": "Sample for ListConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py", + "description": "Sample for UndeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync", "segments": [ { - "end": 52, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 55, "start": 27, "type": "SHORT" }, @@ -5032,17 +10065,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py" }, { "canonical": true, @@ -5052,23 +10085,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issue_models", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.undeploy_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListIssueModels" + "shortName": "UndeployQaScorecardRevision" }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" - }, + "parameters": [ { - "name": "parent", - "type": "str" + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UndeployQaScorecardRevisionRequest" }, { "name": "retry", @@ -5083,14 +10112,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", - "shortName": "list_issue_models" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "undeploy_qa_scorecard_revision" }, - "description": "Sample for ListIssueModels", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py", + "description": "Sample for UndeployQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployQaScorecardRevision_async", "segments": [ { "end": 51, @@ -5123,7 +10152,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_async.py" }, { "canonical": true, @@ -5132,23 +10161,19 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issue_models", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.undeploy_qa_scorecard_revision", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployQaScorecardRevision", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListIssueModels" + "shortName": "UndeployQaScorecardRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.contact_center_insights_v1.types.UndeployQaScorecardRevisionRequest" }, { "name": "retry", @@ -5163,14 +10188,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", - "shortName": "list_issue_models" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecardRevision", + "shortName": "undeploy_qa_scorecard_revision" }, - "description": "Sample for ListIssueModels", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py", + "description": "Sample for UndeployQaScorecardRevision", + "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployQaScorecardRevision_sync", "segments": [ { "end": 51, @@ -5203,7 +10228,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_qa_scorecard_revision_sync.py" }, { "canonical": true, @@ -5213,23 +10238,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issues", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_analysis_rule", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateAnalysisRule", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListIssues" + "shortName": "UpdateAnalysisRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateAnalysisRuleRequest" }, { - "name": "parent", - "type": "str" + "name": "analysis_rule", + "type": "google.cloud.contact_center_insights_v1.types.AnalysisRule" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5244,22 +10273,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", - "shortName": "list_issues" + "resultType": "google.cloud.contact_center_insights_v1.types.AnalysisRule", + "shortName": "update_analysis_rule" }, - "description": "Sample for ListIssues", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py", + "description": "Sample for UpdateAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateAnalysisRule_async", "segments": [ { - "end": 51, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 50, "start": 27, "type": "SHORT" }, @@ -5269,22 +10298,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_async.py" }, { "canonical": true, @@ -5293,23 +10322,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issues", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_analysis_rule", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateAnalysisRule", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListIssues" + "shortName": "UpdateAnalysisRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateAnalysisRuleRequest" }, { - "name": "parent", - "type": "str" + "name": "analysis_rule", + "type": "google.cloud.contact_center_insights_v1.types.AnalysisRule" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5324,22 +10357,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", - "shortName": "list_issues" + "resultType": "google.cloud.contact_center_insights_v1.types.AnalysisRule", + "shortName": "update_analysis_rule" }, - "description": "Sample for ListIssues", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py", + "description": "Sample for UpdateAnalysisRule", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateAnalysisRule_sync", "segments": [ { - "end": 51, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 50, "start": 27, "type": "SHORT" }, @@ -5349,22 +10382,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_analysis_rule_sync.py" }, { "canonical": true, @@ -5374,23 +10407,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_phrase_matchers", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_conversation", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListPhraseMatchers" + "shortName": "UpdateConversation" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" }, { - "name": "parent", - "type": "str" + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5405,22 +10442,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersAsyncPager", - "shortName": "list_phrase_matchers" + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "update_conversation" }, - "description": "Sample for ListPhraseMatchers", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py", + "description": "Sample for UpdateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async", "segments": [ { - "end": 52, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 50, "start": 27, "type": "SHORT" }, @@ -5430,22 +10467,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py" }, { "canonical": true, @@ -5454,23 +10491,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_phrase_matchers", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_conversation", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListPhraseMatchers" + "shortName": "UpdateConversation" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" }, { - "name": "parent", - "type": "str" + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5485,22 +10526,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersPager", - "shortName": "list_phrase_matchers" + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "update_conversation" }, - "description": "Sample for ListPhraseMatchers", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py", + "description": "Sample for UpdateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync", "segments": [ { - "end": 52, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 50, "start": 27, "type": "SHORT" }, @@ -5510,22 +10551,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py" }, { "canonical": true, @@ -5535,23 +10576,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_views", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_feedback_label", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateFeedbackLabel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListViews" + "shortName": "UpdateFeedbackLabel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateFeedbackLabelRequest" }, { - "name": "parent", - "type": "str" + "name": "feedback_label", + "type": "google.cloud.contact_center_insights_v1.types.FeedbackLabel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5566,22 +10611,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager", - "shortName": "list_views" + "resultType": "google.cloud.contact_center_insights_v1.types.FeedbackLabel", + "shortName": "update_feedback_label" }, - "description": "Sample for ListViews", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py", + "description": "Sample for UpdateFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateFeedbackLabel_async", "segments": [ { - "end": 52, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 54, "start": 27, "type": "SHORT" }, @@ -5591,22 +10636,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_async.py" }, { "canonical": true, @@ -5615,23 +10660,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_views", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_feedback_label", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateFeedbackLabel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "ListViews" + "shortName": "UpdateFeedbackLabel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateFeedbackLabelRequest" }, { - "name": "parent", - "type": "str" + "name": "feedback_label", + "type": "google.cloud.contact_center_insights_v1.types.FeedbackLabel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5646,22 +10695,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager", - "shortName": "list_views" + "resultType": "google.cloud.contact_center_insights_v1.types.FeedbackLabel", + "shortName": "update_feedback_label" }, - "description": "Sample for ListViews", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py", + "description": "Sample for UpdateFeedbackLabel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateFeedbackLabel_sync", "segments": [ { - "end": 52, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 54, "start": 27, "type": "SHORT" }, @@ -5671,22 +10720,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_feedback_label_sync.py" }, { "canonical": true, @@ -5696,23 +10745,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.undeploy_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UndeployIssueModel" + "shortName": "UpdateIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" }, { - "name": "name", - "type": "str" + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5727,22 +10780,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "undeploy_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "update_issue_model" }, - "description": "Sample for UndeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py", + "description": "Sample for UpdateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -5752,22 +10805,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py" }, { "canonical": true, @@ -5776,23 +10829,27 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.undeploy_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue_model", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UndeployIssueModel" + "shortName": "UpdateIssueModel" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" }, { - "name": "name", - "type": "str" + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5807,22 +10864,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "undeploy_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "update_issue_model" }, - "description": "Sample for UndeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py", + "description": "Sample for UpdateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -5832,22 +10889,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py" }, { "canonical": true, @@ -5857,23 +10914,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdateConversation" + "shortName": "UpdateIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" }, { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" + "name": "issue", + "type": "google.cloud.contact_center_insights_v1.types.Issue" }, { "name": "update_mask", @@ -5892,14 +10949,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "update_conversation" + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "update_issue" }, - "description": "Sample for UpdateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py", + "description": "Sample for UpdateIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async", "segments": [ { "end": 50, @@ -5932,7 +10989,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py" }, { "canonical": true, @@ -5941,23 +10998,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_conversation", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdateConversation" + "shortName": "UpdateIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" }, { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" + "name": "issue", + "type": "google.cloud.contact_center_insights_v1.types.Issue" }, { "name": "update_mask", @@ -5976,14 +11033,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "update_conversation" + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "update_issue" }, - "description": "Sample for UpdateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py", + "description": "Sample for UpdateIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync", "segments": [ { "end": 50, @@ -6016,7 +11073,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py" }, { "canonical": true, @@ -6026,23 +11083,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_phrase_matcher", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdateIssueModel" + "shortName": "UpdatePhraseMatcher" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" }, { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" }, { "name": "update_mask", @@ -6061,22 +11118,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "update_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "update_phrase_matcher" }, - "description": "Sample for UpdateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py", + "description": "Sample for UpdatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async", "segments": [ { - "end": 50, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 54, "start": 27, "type": "SHORT" }, @@ -6086,22 +11143,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py" }, { "canonical": true, @@ -6110,23 +11167,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue_model", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_phrase_matcher", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdateIssueModel" + "shortName": "UpdatePhraseMatcher" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" }, { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" }, { "name": "update_mask", @@ -6145,22 +11202,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "update_issue_model" + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "update_phrase_matcher" }, - "description": "Sample for UpdateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py", + "description": "Sample for UpdatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync", "segments": [ { - "end": 50, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 54, "start": 27, "type": "SHORT" }, @@ -6170,22 +11227,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py" }, { "canonical": true, @@ -6195,23 +11252,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_qa_question", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateQaQuestion", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdateIssue" + "shortName": "UpdateQaQuestion" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateQaQuestionRequest" }, { - "name": "issue", - "type": "google.cloud.contact_center_insights_v1.types.Issue" + "name": "qa_question", + "type": "google.cloud.contact_center_insights_v1.types.QaQuestion" }, { "name": "update_mask", @@ -6230,14 +11287,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "update_issue" + "resultType": "google.cloud.contact_center_insights_v1.types.QaQuestion", + "shortName": "update_qa_question" }, - "description": "Sample for UpdateIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py", + "description": "Sample for UpdateQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaQuestion_async", "segments": [ { "end": 50, @@ -6270,7 +11327,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_async.py" }, { "canonical": true, @@ -6279,23 +11336,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_qa_question", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateQaQuestion", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdateIssue" + "shortName": "UpdateQaQuestion" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateQaQuestionRequest" }, { - "name": "issue", - "type": "google.cloud.contact_center_insights_v1.types.Issue" + "name": "qa_question", + "type": "google.cloud.contact_center_insights_v1.types.QaQuestion" }, { "name": "update_mask", @@ -6314,14 +11371,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "update_issue" + "resultType": "google.cloud.contact_center_insights_v1.types.QaQuestion", + "shortName": "update_qa_question" }, - "description": "Sample for UpdateIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py", + "description": "Sample for UpdateQaQuestion", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaQuestion_sync", "segments": [ { "end": 50, @@ -6354,7 +11411,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_question_sync.py" }, { "canonical": true, @@ -6364,23 +11421,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", "shortName": "ContactCenterInsightsAsyncClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_qa_scorecard", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateQaScorecard", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdatePhraseMatcher" + "shortName": "UpdateQaScorecard" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateQaScorecardRequest" }, { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + "name": "qa_scorecard", + "type": "google.cloud.contact_center_insights_v1.types.QaScorecard" }, { "name": "update_mask", @@ -6399,22 +11456,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "update_phrase_matcher" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecard", + "shortName": "update_qa_scorecard" }, - "description": "Sample for UpdatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py", + "description": "Sample for UpdateQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaScorecard_async", "segments": [ { - "end": 54, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 50, "start": 27, "type": "SHORT" }, @@ -6424,22 +11481,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 48, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 51, - "start": 49, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_async.py" }, { "canonical": true, @@ -6448,23 +11505,23 @@ "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", "shortName": "ContactCenterInsightsClient" }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_phrase_matcher", + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_qa_scorecard", "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateQaScorecard", "service": { "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", "shortName": "ContactCenterInsights" }, - "shortName": "UpdatePhraseMatcher" + "shortName": "UpdateQaScorecard" }, "parameters": [ { "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" + "type": "google.cloud.contact_center_insights_v1.types.UpdateQaScorecardRequest" }, { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + "name": "qa_scorecard", + "type": "google.cloud.contact_center_insights_v1.types.QaScorecard" }, { "name": "update_mask", @@ -6483,22 +11540,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "update_phrase_matcher" + "resultType": "google.cloud.contact_center_insights_v1.types.QaScorecard", + "shortName": "update_qa_scorecard" }, - "description": "Sample for UpdatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py", + "description": "Sample for UpdateQaScorecard", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateQaScorecard_sync", "segments": [ { - "end": 54, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 50, "start": 27, "type": "SHORT" }, @@ -6508,22 +11565,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 48, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 51, - "start": 49, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py" + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_qa_scorecard_sync.py" }, { "canonical": true, diff --git a/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py b/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py index 10d05e634fa6..9790836741a6 100644 --- a/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py +++ b/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py @@ -41,44 +41,75 @@ class contact_center_insightsCallTransformer(cst.CSTTransformer): METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'bulk_analyze_conversations': ('parent', 'filter', 'analysis_percentage', 'annotator_selector', ), 'bulk_delete_conversations': ('parent', 'filter', 'max_delete_count', 'force', ), + 'bulk_download_feedback_labels': ('parent', 'gcs_destination', 'filter', 'max_download_count', 'feedback_label_type', 'conversation_filter', 'template_qa_scorecard_id', ), + 'bulk_upload_feedback_labels': ('parent', 'gcs_source', 'validate_only', ), 'calculate_issue_model_stats': ('issue_model', ), 'calculate_stats': ('location', 'filter', ), 'create_analysis': ('parent', 'analysis', ), + 'create_analysis_rule': ('parent', 'analysis_rule', ), 'create_conversation': ('parent', 'conversation', 'conversation_id', ), + 'create_feedback_label': ('parent', 'feedback_label', 'feedback_label_id', ), 'create_issue_model': ('parent', 'issue_model', ), 'create_phrase_matcher': ('parent', 'phrase_matcher', ), + 'create_qa_question': ('parent', 'qa_question', 'qa_question_id', ), + 'create_qa_scorecard': ('parent', 'qa_scorecard', 'qa_scorecard_id', ), + 'create_qa_scorecard_revision': ('parent', 'qa_scorecard_revision', 'qa_scorecard_revision_id', ), 'create_view': ('parent', 'view', ), 'delete_analysis': ('name', ), + 'delete_analysis_rule': ('name', ), 'delete_conversation': ('name', 'force', ), + 'delete_feedback_label': ('name', ), 'delete_issue': ('name', ), 'delete_issue_model': ('name', ), 'delete_phrase_matcher': ('name', ), + 'delete_qa_question': ('name', ), + 'delete_qa_scorecard': ('name', 'force', ), + 'delete_qa_scorecard_revision': ('name', 'force', ), 'delete_view': ('name', ), 'deploy_issue_model': ('name', ), + 'deploy_qa_scorecard_revision': ('name', ), 'export_insights_data': ('parent', 'big_query_destination', 'filter', 'kms_key', 'write_disposition', ), 'export_issue_model': ('name', 'gcs_destination', ), 'get_analysis': ('name', ), + 'get_analysis_rule': ('name', ), 'get_conversation': ('name', 'view', ), 'get_encryption_spec': ('name', ), + 'get_feedback_label': ('name', ), 'get_issue': ('name', ), 'get_issue_model': ('name', ), 'get_phrase_matcher': ('name', ), + 'get_qa_question': ('name', ), + 'get_qa_scorecard': ('name', ), + 'get_qa_scorecard_revision': ('name', ), 'get_settings': ('name', ), 'get_view': ('name', ), 'import_issue_model': ('parent', 'gcs_source', 'create_new_model', ), 'ingest_conversations': ('parent', 'gcs_source', 'transcript_object_config', 'conversation_config', 'redaction_config', 'speech_config', 'sample_size', ), 'initialize_encryption_spec': ('encryption_spec', ), + 'list_all_feedback_labels': ('parent', 'page_size', 'page_token', 'filter', ), 'list_analyses': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_analysis_rules': ('parent', 'page_size', 'page_token', ), 'list_conversations': ('parent', 'page_size', 'page_token', 'filter', 'order_by', 'view', ), + 'list_feedback_labels': ('parent', 'filter', 'page_size', 'page_token', ), 'list_issue_models': ('parent', ), 'list_issues': ('parent', ), 'list_phrase_matchers': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_qa_questions': ('parent', 'page_size', 'page_token', ), + 'list_qa_scorecard_revisions': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_qa_scorecards': ('parent', 'page_size', 'page_token', ), 'list_views': ('parent', 'page_size', 'page_token', ), + 'query_metrics': ('location', 'filter', 'time_granularity', 'dimensions', 'measure_mask', ), + 'tune_qa_scorecard_revision': ('parent', 'filter', 'validate_only', ), 'undeploy_issue_model': ('name', ), + 'undeploy_qa_scorecard_revision': ('name', ), + 'update_analysis_rule': ('analysis_rule', 'update_mask', ), 'update_conversation': ('conversation', 'update_mask', ), + 'update_feedback_label': ('feedback_label', 'update_mask', ), 'update_issue': ('issue', 'update_mask', ), 'update_issue_model': ('issue_model', 'update_mask', ), 'update_phrase_matcher': ('phrase_matcher', 'update_mask', ), + 'update_qa_question': ('qa_question', 'update_mask', ), + 'update_qa_scorecard': ('qa_scorecard', 'update_mask', ), 'update_settings': ('settings', 'update_mask', ), 'update_view': ('view', 'update_mask', ), 'upload_conversation': ('parent', 'conversation', 'conversation_id', 'redaction_config', 'speech_config', ), diff --git a/packages/google-cloud-contact-center-insights/setup.py b/packages/google-cloud-contact-center-insights/setup.py index edb16fca7403..c42006cbbb36 100644 --- a/packages/google-cloud-contact-center-insights/setup.py +++ b/packages/google-cloud-contact-center-insights/setup.py @@ -48,6 +48,7 @@ "proto-plus >= 1.22.3, <2.0.0dev", "proto-plus >= 1.25.0, <2.0.0dev; python_version >= '3.13'", "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] extras = {} url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-contact-center-insights" diff --git a/packages/google-cloud-contact-center-insights/testing/constraints-3.10.txt b/packages/google-cloud-contact-center-insights/testing/constraints-3.10.txt index ed7f9aed2559..ad3f0fa58e2d 100644 --- a/packages/google-cloud-contact-center-insights/testing/constraints-3.10.txt +++ b/packages/google-cloud-contact-center-insights/testing/constraints-3.10.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +grpc-google-iam-v1 diff --git a/packages/google-cloud-contact-center-insights/testing/constraints-3.11.txt b/packages/google-cloud-contact-center-insights/testing/constraints-3.11.txt index ed7f9aed2559..ad3f0fa58e2d 100644 --- a/packages/google-cloud-contact-center-insights/testing/constraints-3.11.txt +++ b/packages/google-cloud-contact-center-insights/testing/constraints-3.11.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +grpc-google-iam-v1 diff --git a/packages/google-cloud-contact-center-insights/testing/constraints-3.12.txt b/packages/google-cloud-contact-center-insights/testing/constraints-3.12.txt index ed7f9aed2559..ad3f0fa58e2d 100644 --- a/packages/google-cloud-contact-center-insights/testing/constraints-3.12.txt +++ b/packages/google-cloud-contact-center-insights/testing/constraints-3.12.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +grpc-google-iam-v1 diff --git a/packages/google-cloud-contact-center-insights/testing/constraints-3.13.txt b/packages/google-cloud-contact-center-insights/testing/constraints-3.13.txt index ed7f9aed2559..ad3f0fa58e2d 100644 --- a/packages/google-cloud-contact-center-insights/testing/constraints-3.13.txt +++ b/packages/google-cloud-contact-center-insights/testing/constraints-3.13.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +grpc-google-iam-v1 diff --git a/packages/google-cloud-contact-center-insights/testing/constraints-3.7.txt b/packages/google-cloud-contact-center-insights/testing/constraints-3.7.txt index fc812592b0ee..a81fb6bcd05c 100644 --- a/packages/google-cloud-contact-center-insights/testing/constraints-3.7.txt +++ b/packages/google-cloud-contact-center-insights/testing/constraints-3.7.txt @@ -8,3 +8,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 protobuf==3.20.2 +grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-contact-center-insights/testing/constraints-3.8.txt b/packages/google-cloud-contact-center-insights/testing/constraints-3.8.txt index ed7f9aed2559..ad3f0fa58e2d 100644 --- a/packages/google-cloud-contact-center-insights/testing/constraints-3.8.txt +++ b/packages/google-cloud-contact-center-insights/testing/constraints-3.8.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +grpc-google-iam-v1 diff --git a/packages/google-cloud-contact-center-insights/testing/constraints-3.9.txt b/packages/google-cloud-contact-center-insights/testing/constraints-3.9.txt index ed7f9aed2559..ad3f0fa58e2d 100644 --- a/packages/google-cloud-contact-center-insights/testing/constraints-3.9.txt +++ b/packages/google-cloud-contact-center-insights/testing/constraints-3.9.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +grpc-google-iam-v1 diff --git a/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py b/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py index bf8f9a66c041..3adb4052ae0d 100644 --- a/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py +++ b/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py @@ -59,6 +59,9 @@ import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import options_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore @@ -14084,11 +14087,11 @@ async def test_update_settings_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetEncryptionSpecRequest, + contact_center_insights.CreateAnalysisRuleRequest, dict, ], ) -def test_get_encryption_spec(request_type, transport: str = "grpc"): +def test_create_analysis_rule(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -14100,28 +14103,34 @@ def test_get_encryption_spec(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.EncryptionSpec( + call.return_value = resources.AnalysisRule( name="name_value", - kms_key="kms_key_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, ) - response = client.get_encryption_spec(request) + response = client.create_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = contact_center_insights.GetEncryptionSpecRequest() + request = contact_center_insights.CreateAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.EncryptionSpec) + assert isinstance(response, resources.AnalysisRule) assert response.name == "name_value" - assert response.kms_key == "kms_key_value" + assert response.display_name == "display_name_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True -def test_get_encryption_spec_non_empty_request_with_auto_populated_field(): +def test_create_analysis_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( @@ -14132,26 +14141,26 @@ def test_get_encryption_spec_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = contact_center_insights.GetEncryptionSpecRequest( - name="name_value", + request = contact_center_insights.CreateAnalysisRuleRequest( + parent="parent_value", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_encryption_spec(request=request) + client.create_analysis_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetEncryptionSpecRequest( - name="name_value", + assert args[0] == contact_center_insights.CreateAnalysisRuleRequest( + parent="parent_value", ) -def test_get_encryption_spec_use_cached_wrapped_rpc(): +def test_create_analysis_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -14166,7 +14175,7 @@ def test_get_encryption_spec_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.get_encryption_spec in client._transport._wrapped_methods + client._transport.create_analysis_rule in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -14175,15 +14184,15 @@ def test_get_encryption_spec_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_encryption_spec + client._transport.create_analysis_rule ] = mock_rpc request = {} - client.get_encryption_spec(request) + client.create_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_encryption_spec(request) + client.create_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14191,7 +14200,7 @@ def test_get_encryption_spec_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_encryption_spec_async_use_cached_wrapped_rpc( +async def test_create_analysis_rule_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -14208,7 +14217,7 @@ async def test_get_encryption_spec_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.get_encryption_spec + client._client._transport.create_analysis_rule in client._client._transport._wrapped_methods ) @@ -14216,16 +14225,16 @@ async def test_get_encryption_spec_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_encryption_spec + client._client._transport.create_analysis_rule ] = mock_rpc request = {} - await client.get_encryption_spec(request) + await client.create_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_encryption_spec(request) + await client.create_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14233,9 +14242,9 @@ async def test_get_encryption_spec_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_encryption_spec_async( +async def test_create_analysis_rule_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.GetEncryptionSpecRequest, + request_type=contact_center_insights.CreateAnalysisRuleRequest, ): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), @@ -14248,51 +14257,57 @@ async def test_get_encryption_spec_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.EncryptionSpec( + resources.AnalysisRule( name="name_value", - kms_key="kms_key_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, ) ) - response = await client.get_encryption_spec(request) + response = await client.create_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = contact_center_insights.GetEncryptionSpecRequest() + request = contact_center_insights.CreateAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.EncryptionSpec) + assert isinstance(response, resources.AnalysisRule) assert response.name == "name_value" - assert response.kms_key == "kms_key_value" + assert response.display_name == "display_name_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True @pytest.mark.asyncio -async def test_get_encryption_spec_async_from_dict(): - await test_get_encryption_spec_async(request_type=dict) +async def test_create_analysis_rule_async_from_dict(): + await test_create_analysis_rule_async(request_type=dict) -def test_get_encryption_spec_field_headers(): +def test_create_analysis_rule_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.GetEncryptionSpecRequest() + request = contact_center_insights.CreateAnalysisRuleRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: - call.return_value = resources.EncryptionSpec() - client.get_encryption_spec(request) + call.return_value = resources.AnalysisRule() + client.create_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -14303,30 +14318,30 @@ def test_get_encryption_spec_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_encryption_spec_field_headers_async(): +async def test_create_analysis_rule_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.GetEncryptionSpecRequest() + request = contact_center_insights.CreateAnalysisRuleRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.EncryptionSpec() + resources.AnalysisRule() ) - await client.get_encryption_spec(request) + await client.create_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -14337,37 +14352,41 @@ async def test_get_encryption_spec_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_get_encryption_spec_flattened(): +def test_create_analysis_rule_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.EncryptionSpec() + call.return_value = resources.AnalysisRule() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_encryption_spec( - name="name_value", + client.create_analysis_rule( + parent="parent_value", + analysis_rule=resources.AnalysisRule(name="name_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].analysis_rule + mock_val = resources.AnalysisRule(name="name_value") assert arg == mock_val -def test_get_encryption_spec_flattened_error(): +def test_create_analysis_rule_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -14375,45 +14394,50 @@ def test_get_encryption_spec_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_encryption_spec( - contact_center_insights.GetEncryptionSpecRequest(), - name="name_value", + client.create_analysis_rule( + contact_center_insights.CreateAnalysisRuleRequest(), + parent="parent_value", + analysis_rule=resources.AnalysisRule(name="name_value"), ) @pytest.mark.asyncio -async def test_get_encryption_spec_flattened_async(): +async def test_create_analysis_rule_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.EncryptionSpec() + call.return_value = resources.AnalysisRule() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.EncryptionSpec() + resources.AnalysisRule() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_encryption_spec( - name="name_value", + response = await client.create_analysis_rule( + parent="parent_value", + analysis_rule=resources.AnalysisRule(name="name_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].analysis_rule + mock_val = resources.AnalysisRule(name="name_value") assert arg == mock_val @pytest.mark.asyncio -async def test_get_encryption_spec_flattened_error_async(): +async def test_create_analysis_rule_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) @@ -14421,20 +14445,21 @@ async def test_get_encryption_spec_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_encryption_spec( - contact_center_insights.GetEncryptionSpecRequest(), - name="name_value", + await client.create_analysis_rule( + contact_center_insights.CreateAnalysisRuleRequest(), + parent="parent_value", + analysis_rule=resources.AnalysisRule(name="name_value"), ) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.InitializeEncryptionSpecRequest, + contact_center_insights.GetAnalysisRuleRequest, dict, ], ) -def test_initialize_encryption_spec(request_type, transport: str = "grpc"): +def test_get_analysis_rule(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -14446,23 +14471,34 @@ def test_initialize_encryption_spec(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.initialize_encryption_spec(request) + call.return_value = resources.AnalysisRule( + name="name_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, + ) + response = client.get_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = contact_center_insights.InitializeEncryptionSpecRequest() + request = contact_center_insights.GetAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, resources.AnalysisRule) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True -def test_initialize_encryption_spec_non_empty_request_with_auto_populated_field(): +def test_get_analysis_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( @@ -14473,22 +14509,26 @@ def test_initialize_encryption_spec_non_empty_request_with_auto_populated_field( # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = contact_center_insights.InitializeEncryptionSpecRequest() + request = contact_center_insights.GetAnalysisRuleRequest( + name="name_value", + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_analysis_rule), "__call__" ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.initialize_encryption_spec(request=request) + client.get_analysis_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.InitializeEncryptionSpecRequest() + assert args[0] == contact_center_insights.GetAnalysisRuleRequest( + name="name_value", + ) -def test_initialize_encryption_spec_use_cached_wrapped_rpc(): +def test_get_analysis_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -14502,10 +14542,7 @@ def test_initialize_encryption_spec_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.initialize_encryption_spec - in client._transport._wrapped_methods - ) + assert client._transport.get_analysis_rule in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -14513,20 +14550,15 @@ def test_initialize_encryption_spec_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.initialize_encryption_spec + client._transport.get_analysis_rule ] = mock_rpc request = {} - client.initialize_encryption_spec(request) + client.get_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.initialize_encryption_spec(request) + client.get_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14534,7 +14566,7 @@ def test_initialize_encryption_spec_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_initialize_encryption_spec_async_use_cached_wrapped_rpc( +async def test_get_analysis_rule_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -14551,7 +14583,7 @@ async def test_initialize_encryption_spec_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.initialize_encryption_spec + client._client._transport.get_analysis_rule in client._client._transport._wrapped_methods ) @@ -14559,21 +14591,16 @@ async def test_initialize_encryption_spec_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.initialize_encryption_spec + client._client._transport.get_analysis_rule ] = mock_rpc request = {} - await client.initialize_encryption_spec(request) + await client.get_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.initialize_encryption_spec(request) + await client.get_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14581,9 +14608,9 @@ async def test_initialize_encryption_spec_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_initialize_encryption_spec_async( +async def test_get_analysis_rule_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.InitializeEncryptionSpecRequest, + request_type=contact_center_insights.GetAnalysisRuleRequest, ): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), @@ -14596,46 +14623,57 @@ async def test_initialize_encryption_spec_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + resources.AnalysisRule( + name="name_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, + ) ) - response = await client.initialize_encryption_spec(request) + response = await client.get_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = contact_center_insights.InitializeEncryptionSpecRequest() + request = contact_center_insights.GetAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, resources.AnalysisRule) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True @pytest.mark.asyncio -async def test_initialize_encryption_spec_async_from_dict(): - await test_initialize_encryption_spec_async(request_type=dict) +async def test_get_analysis_rule_async_from_dict(): + await test_get_analysis_rule_async(request_type=dict) -def test_initialize_encryption_spec_field_headers(): +def test_get_analysis_rule_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.InitializeEncryptionSpecRequest() + request = contact_center_insights.GetAnalysisRuleRequest() - request.encryption_spec.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_analysis_rule), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.initialize_encryption_spec(request) + call.return_value = resources.AnalysisRule() + client.get_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -14646,30 +14684,30 @@ def test_initialize_encryption_spec_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "encryption_spec.name=name_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_initialize_encryption_spec_field_headers_async(): +async def test_get_analysis_rule_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.InitializeEncryptionSpecRequest() + request = contact_center_insights.GetAnalysisRuleRequest() - request.encryption_spec.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_analysis_rule), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") + resources.AnalysisRule() ) - await client.initialize_encryption_spec(request) + await client.get_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -14680,37 +14718,37 @@ async def test_initialize_encryption_spec_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "encryption_spec.name=name_value", + "name=name_value", ) in kw["metadata"] -def test_initialize_encryption_spec_flattened(): +def test_get_analysis_rule_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = resources.AnalysisRule() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.initialize_encryption_spec( - encryption_spec=resources.EncryptionSpec(name="name_value"), + client.get_analysis_rule( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].encryption_spec - mock_val = resources.EncryptionSpec(name="name_value") + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_initialize_encryption_spec_flattened_error(): +def test_get_analysis_rule_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -14718,45 +14756,45 @@ def test_initialize_encryption_spec_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.initialize_encryption_spec( - contact_center_insights.InitializeEncryptionSpecRequest(), - encryption_spec=resources.EncryptionSpec(name="name_value"), + client.get_analysis_rule( + contact_center_insights.GetAnalysisRuleRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_initialize_encryption_spec_flattened_async(): +async def test_get_analysis_rule_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_analysis_rule), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = resources.AnalysisRule() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + resources.AnalysisRule() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.initialize_encryption_spec( - encryption_spec=resources.EncryptionSpec(name="name_value"), + response = await client.get_analysis_rule( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].encryption_spec - mock_val = resources.EncryptionSpec(name="name_value") + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_initialize_encryption_spec_flattened_error_async(): +async def test_get_analysis_rule_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) @@ -14764,20 +14802,20 @@ async def test_initialize_encryption_spec_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.initialize_encryption_spec( - contact_center_insights.InitializeEncryptionSpecRequest(), - encryption_spec=resources.EncryptionSpec(name="name_value"), + await client.get_analysis_rule( + contact_center_insights.GetAnalysisRuleRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.CreateViewRequest, + contact_center_insights.ListAnalysisRulesRequest, dict, ], ) -def test_create_view(request_type, transport: str = "grpc"): +def test_list_analysis_rules(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -14788,29 +14826,27 @@ def test_create_view(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", + call.return_value = contact_center_insights.ListAnalysisRulesResponse( + next_page_token="next_page_token_value", ) - response = client.create_view(request) + response = client.list_analysis_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = contact_center_insights.CreateViewRequest() + request = contact_center_insights.ListAnalysisRulesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert isinstance(response, pagers.ListAnalysisRulesPager) + assert response.next_page_token == "next_page_token_value" -def test_create_view_non_empty_request_with_auto_populated_field(): +def test_list_analysis_rules_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( @@ -14821,24 +14857,28 @@ def test_create_view_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = contact_center_insights.CreateViewRequest( + request = contact_center_insights.ListAnalysisRulesRequest( parent="parent_value", + page_token="page_token_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.create_view(request=request) + client.list_analysis_rules(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateViewRequest( + assert args[0] == contact_center_insights.ListAnalysisRulesRequest( parent="parent_value", + page_token="page_token_value", ) -def test_create_view_use_cached_wrapped_rpc(): +def test_list_analysis_rules_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -14852,21 +14892,25 @@ def test_create_view_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.create_view in client._transport._wrapped_methods + assert ( + client._transport.list_analysis_rules in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.create_view] = mock_rpc + client._transport._wrapped_methods[ + client._transport.list_analysis_rules + ] = mock_rpc request = {} - client.create_view(request) + client.list_analysis_rules(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.create_view(request) + client.list_analysis_rules(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14874,7 +14918,7 @@ def test_create_view_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_create_view_async_use_cached_wrapped_rpc( +async def test_list_analysis_rules_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -14891,7 +14935,7 @@ async def test_create_view_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.create_view + client._client._transport.list_analysis_rules in client._client._transport._wrapped_methods ) @@ -14899,16 +14943,16 @@ async def test_create_view_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.create_view + client._client._transport.list_analysis_rules ] = mock_rpc request = {} - await client.create_view(request) + await client.list_analysis_rules(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.create_view(request) + await client.list_analysis_rules(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14916,9 +14960,9 @@ async def test_create_view_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_view_async( +async def test_list_analysis_rules_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.CreateViewRequest, + request_type=contact_center_insights.ListAnalysisRulesRequest, ): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), @@ -14930,50 +14974,50 @@ async def test_create_view_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", + contact_center_insights.ListAnalysisRulesResponse( + next_page_token="next_page_token_value", ) ) - response = await client.create_view(request) + response = await client.list_analysis_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = contact_center_insights.CreateViewRequest() + request = contact_center_insights.ListAnalysisRulesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert isinstance(response, pagers.ListAnalysisRulesAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_create_view_async_from_dict(): - await test_create_view_async(request_type=dict) +async def test_list_analysis_rules_async_from_dict(): + await test_list_analysis_rules_async(request_type=dict) -def test_create_view_field_headers(): +def test_list_analysis_rules_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateViewRequest() + request = contact_center_insights.ListAnalysisRulesRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: - call.return_value = resources.View() - client.create_view(request) + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: + call.return_value = contact_center_insights.ListAnalysisRulesResponse() + client.list_analysis_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -14989,21 +15033,25 @@ def test_create_view_field_headers(): @pytest.mark.asyncio -async def test_create_view_field_headers_async(): +async def test_list_analysis_rules_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateViewRequest() + request = contact_center_insights.ListAnalysisRulesRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - await client.create_view(request) + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAnalysisRulesResponse() + ) + await client.list_analysis_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -15018,20 +15066,21 @@ async def test_create_view_field_headers_async(): ) in kw["metadata"] -def test_create_view_flattened(): +def test_list_analysis_rules_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View() + call.return_value = contact_center_insights.ListAnalysisRulesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_view( + client.list_analysis_rules( parent="parent_value", - view=resources.View(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -15041,12 +15090,9 @@ def test_create_view_flattened(): arg = args[0].parent mock_val = "parent_value" assert arg == mock_val - arg = args[0].view - mock_val = resources.View(name="name_value") - assert arg == mock_val -def test_create_view_flattened_error(): +def test_list_analysis_rules_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -15054,30 +15100,32 @@ def test_create_view_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_view( - contact_center_insights.CreateViewRequest(), + client.list_analysis_rules( + contact_center_insights.ListAnalysisRulesRequest(), parent="parent_value", - view=resources.View(name="name_value"), ) @pytest.mark.asyncio -async def test_create_view_flattened_async(): +async def test_list_analysis_rules_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View() + call.return_value = contact_center_insights.ListAnalysisRulesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAnalysisRulesResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_view( + response = await client.list_analysis_rules( parent="parent_value", - view=resources.View(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -15087,13 +15135,10 @@ async def test_create_view_flattened_async(): arg = args[0].parent mock_val = "parent_value" assert arg == mock_val - arg = args[0].view - mock_val = resources.View(name="name_value") - assert arg == mock_val @pytest.mark.asyncio -async def test_create_view_flattened_error_async(): +async def test_list_analysis_rules_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) @@ -15101,21 +15146,222 @@ async def test_create_view_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.create_view( - contact_center_insights.CreateViewRequest(), + await client.list_analysis_rules( + contact_center_insights.ListAnalysisRulesRequest(), parent="parent_value", - view=resources.View(name="name_value"), ) +def test_list_analysis_rules_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[], + next_page_token="def", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_analysis_rules(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.AnalysisRule) for i in results) + + +def test_list_analysis_rules_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[], + next_page_token="def", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_analysis_rules(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_analysis_rules_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analysis_rules), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[], + next_page_token="def", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_analysis_rules( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.AnalysisRule) for i in responses) + + +@pytest.mark.asyncio +async def test_list_analysis_rules_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analysis_rules), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[], + next_page_token="def", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_analysis_rules(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetViewRequest, + contact_center_insights.UpdateAnalysisRuleRequest, dict, ], ) -def test_get_view(request_type, transport: str = "grpc"): +def test_update_analysis_rule(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15126,29 +15372,35 @@ def test_get_view(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View( + call.return_value = resources.AnalysisRule( name="name_value", display_name="display_name_value", - value="value_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, ) - response = client.get_view(request) + response = client.update_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = contact_center_insights.GetViewRequest() + request = contact_center_insights.UpdateAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) + assert isinstance(response, resources.AnalysisRule) assert response.name == "name_value" assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True -def test_get_view_non_empty_request_with_auto_populated_field(): +def test_update_analysis_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( @@ -15159,24 +15411,22 @@ def test_get_view_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = contact_center_insights.GetViewRequest( - name="name_value", - ) + request = contact_center_insights.UpdateAnalysisRuleRequest() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_view(request=request) + client.update_analysis_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetViewRequest( - name="name_value", - ) + assert args[0] == contact_center_insights.UpdateAnalysisRuleRequest() -def test_get_view_use_cached_wrapped_rpc(): +def test_update_analysis_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -15190,21 +15440,25 @@ def test_get_view_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_view in client._transport._wrapped_methods + assert ( + client._transport.update_analysis_rule in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_view] = mock_rpc + client._transport._wrapped_methods[ + client._transport.update_analysis_rule + ] = mock_rpc request = {} - client.get_view(request) + client.update_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_view(request) + client.update_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -15212,7 +15466,9 @@ def test_get_view_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_view_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_update_analysis_rule_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -15227,7 +15483,7 @@ async def test_get_view_async_use_cached_wrapped_rpc(transport: str = "grpc_asyn # Ensure method has been cached assert ( - client._client._transport.get_view + client._client._transport.update_analysis_rule in client._client._transport._wrapped_methods ) @@ -15235,16 +15491,16 @@ async def test_get_view_async_use_cached_wrapped_rpc(transport: str = "grpc_asyn mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_view + client._client._transport.update_analysis_rule ] = mock_rpc request = {} - await client.get_view(request) + await client.update_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_view(request) + await client.update_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -15252,8 +15508,9 @@ async def test_get_view_async_use_cached_wrapped_rpc(transport: str = "grpc_asyn @pytest.mark.asyncio -async def test_get_view_async( - transport: str = "grpc_asyncio", request_type=contact_center_insights.GetViewRequest +async def test_update_analysis_rule_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UpdateAnalysisRuleRequest, ): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), @@ -15265,50 +15522,58 @@ async def test_get_view_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.View( + resources.AnalysisRule( name="name_value", display_name="display_name_value", - value="value_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, ) ) - response = await client.get_view(request) + response = await client.update_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = contact_center_insights.GetViewRequest() + request = contact_center_insights.UpdateAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) + assert isinstance(response, resources.AnalysisRule) assert response.name == "name_value" assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True @pytest.mark.asyncio -async def test_get_view_async_from_dict(): - await test_get_view_async(request_type=dict) +async def test_update_analysis_rule_async_from_dict(): + await test_update_analysis_rule_async(request_type=dict) -def test_get_view_field_headers(): +def test_update_analysis_rule_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.GetViewRequest() + request = contact_center_insights.UpdateAnalysisRuleRequest() - request.name = "name_value" + request.analysis_rule.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: - call.return_value = resources.View() - client.get_view(request) + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: + call.return_value = resources.AnalysisRule() + client.update_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -15319,26 +15584,30 @@ def test_get_view_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "analysis_rule.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_view_field_headers_async(): +async def test_update_analysis_rule_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.GetViewRequest() + request = contact_center_insights.UpdateAnalysisRuleRequest() - request.name = "name_value" + request.analysis_rule.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - await client.get_view(request) + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AnalysisRule() + ) + await client.update_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -15349,35 +15618,41 @@ async def test_get_view_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "analysis_rule.name=name_value", ) in kw["metadata"] -def test_get_view_flattened(): +def test_update_analysis_rule_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View() + call.return_value = resources.AnalysisRule() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_view( - name="name_value", + client.update_analysis_rule( + analysis_rule=resources.AnalysisRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].analysis_rule + mock_val = resources.AnalysisRule(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val -def test_get_view_flattened_error(): +def test_update_analysis_rule_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -15385,41 +15660,50 @@ def test_get_view_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_view( - contact_center_insights.GetViewRequest(), - name="name_value", + client.update_analysis_rule( + contact_center_insights.UpdateAnalysisRuleRequest(), + analysis_rule=resources.AnalysisRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio -async def test_get_view_flattened_async(): +async def test_update_analysis_rule_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View() + call.return_value = resources.AnalysisRule() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AnalysisRule() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_view( - name="name_value", + response = await client.update_analysis_rule( + analysis_rule=resources.AnalysisRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].analysis_rule + mock_val = resources.AnalysisRule(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val @pytest.mark.asyncio -async def test_get_view_flattened_error_async(): +async def test_update_analysis_rule_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) @@ -15427,20 +15711,21 @@ async def test_get_view_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_view( - contact_center_insights.GetViewRequest(), - name="name_value", + await client.update_analysis_rule( + contact_center_insights.UpdateAnalysisRuleRequest(), + analysis_rule=resources.AnalysisRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ListViewsRequest, + contact_center_insights.DeleteAnalysisRuleRequest, dict, ], ) -def test_list_views(request_type, transport: str = "grpc"): +def test_delete_analysis_rule(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15451,25 +15736,24 @@ def test_list_views(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListViewsResponse( - next_page_token="next_page_token_value", - ) - response = client.list_views(request) + call.return_value = None + response = client.delete_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = contact_center_insights.ListViewsRequest() + request = contact_center_insights.DeleteAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListViewsPager) - assert response.next_page_token == "next_page_token_value" + assert response is None -def test_list_views_non_empty_request_with_auto_populated_field(): +def test_delete_analysis_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( @@ -15480,26 +15764,26 @@ def test_list_views_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = contact_center_insights.ListViewsRequest( - parent="parent_value", - page_token="page_token_value", + request = contact_center_insights.DeleteAnalysisRuleRequest( + name="name_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.list_views(request=request) + client.delete_analysis_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListViewsRequest( - parent="parent_value", - page_token="page_token_value", + assert args[0] == contact_center_insights.DeleteAnalysisRuleRequest( + name="name_value", ) -def test_list_views_use_cached_wrapped_rpc(): +def test_delete_analysis_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -15513,21 +15797,25 @@ def test_list_views_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_views in client._transport._wrapped_methods + assert ( + client._transport.delete_analysis_rule in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_views] = mock_rpc + client._transport._wrapped_methods[ + client._transport.delete_analysis_rule + ] = mock_rpc request = {} - client.list_views(request) + client.delete_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_views(request) + client.delete_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -15535,7 +15823,9 @@ def test_list_views_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_list_views_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_delete_analysis_rule_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -15550,7 +15840,7 @@ async def test_list_views_async_use_cached_wrapped_rpc(transport: str = "grpc_as # Ensure method has been cached assert ( - client._client._transport.list_views + client._client._transport.delete_analysis_rule in client._client._transport._wrapped_methods ) @@ -15558,16 +15848,16 @@ async def test_list_views_async_use_cached_wrapped_rpc(transport: str = "grpc_as mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.list_views + client._client._transport.delete_analysis_rule ] = mock_rpc request = {} - await client.list_views(request) + await client.delete_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.list_views(request) + await client.delete_analysis_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -15575,9 +15865,9 @@ async def test_list_views_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_list_views_async( +async def test_delete_analysis_rule_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.ListViewsRequest, + request_type=contact_center_insights.DeleteAnalysisRuleRequest, ): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), @@ -15589,46 +15879,45 @@ async def test_list_views_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListViewsResponse( - next_page_token="next_page_token_value", - ) - ) - response = await client.list_views(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = contact_center_insights.ListViewsRequest() + request = contact_center_insights.DeleteAnalysisRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListViewsAsyncPager) - assert response.next_page_token == "next_page_token_value" + assert response is None @pytest.mark.asyncio -async def test_list_views_async_from_dict(): - await test_list_views_async(request_type=dict) +async def test_delete_analysis_rule_async_from_dict(): + await test_delete_analysis_rule_async(request_type=dict) -def test_list_views_field_headers(): +def test_delete_analysis_rule_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.ListViewsRequest() + request = contact_center_insights.DeleteAnalysisRuleRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: - call.return_value = contact_center_insights.ListViewsResponse() - client.list_views(request) + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: + call.return_value = None + client.delete_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -15639,28 +15928,28 @@ def test_list_views_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_views_field_headers_async(): +async def test_delete_analysis_rule_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.ListViewsRequest() + request = contact_center_insights.DeleteAnalysisRuleRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListViewsResponse() - ) - await client.list_views(request) + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_analysis_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -15671,35 +15960,37 @@ async def test_list_views_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] -def test_list_views_flattened(): +def test_delete_analysis_rule_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListViewsResponse() + call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_views( - parent="parent_value", + client.delete_analysis_rule( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_list_views_flattened_error(): +def test_delete_analysis_rule_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -15707,43 +15998,43 @@ def test_list_views_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_views( - contact_center_insights.ListViewsRequest(), - parent="parent_value", + client.delete_analysis_rule( + contact_center_insights.DeleteAnalysisRuleRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_list_views_flattened_async(): +async def test_delete_analysis_rule_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListViewsResponse() + call.return_value = None - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListViewsResponse() - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_views( - parent="parent_value", + response = await client.delete_analysis_rule( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_list_views_flattened_error_async(): +async def test_delete_analysis_rule_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) @@ -15751,214 +16042,20 @@ async def test_list_views_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_views( - contact_center_insights.ListViewsRequest(), - parent="parent_value", - ) - - -def test_list_views_pager(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token="abc", - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token="def", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token="ghi", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_views(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.View) for i in results) - - -def test_list_views_pages(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token="abc", - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token="def", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token="ghi", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, - ) - pages = list(client.list_views(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_list_views_async_pager(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token="abc", - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token="def", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token="ghi", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_views( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.View) for i in responses) - - -@pytest.mark.asyncio -async def test_list_views_async_pages(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token="abc", - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token="def", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token="ghi", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, + await client.delete_analysis_rule( + contact_center_insights.DeleteAnalysisRuleRequest(), + name="name_value", ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_views(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UpdateViewRequest, + contact_center_insights.GetEncryptionSpecRequest, dict, ], ) -def test_update_view(request_type, transport: str = "grpc"): +def test_get_encryption_spec(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15969,29 +16066,29 @@ def test_update_view(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View( + call.return_value = resources.EncryptionSpec( name="name_value", - display_name="display_name_value", - value="value_value", + kms_key="kms_key_value", ) - response = client.update_view(request) + response = client.get_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = contact_center_insights.UpdateViewRequest() + request = contact_center_insights.GetEncryptionSpecRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) + assert isinstance(response, resources.EncryptionSpec) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert response.kms_key == "kms_key_value" -def test_update_view_non_empty_request_with_auto_populated_field(): +def test_get_encryption_spec_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( @@ -16002,20 +16099,26 @@ def test_update_view_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = contact_center_insights.UpdateViewRequest() + request = contact_center_insights.GetEncryptionSpecRequest( + name="name_value", + ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.update_view(request=request) + client.get_encryption_spec(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateViewRequest() + assert args[0] == contact_center_insights.GetEncryptionSpecRequest( + name="name_value", + ) -def test_update_view_use_cached_wrapped_rpc(): +def test_get_encryption_spec_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -16029,21 +16132,25 @@ def test_update_view_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.update_view in client._transport._wrapped_methods + assert ( + client._transport.get_encryption_spec in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.update_view] = mock_rpc + client._transport._wrapped_methods[ + client._transport.get_encryption_spec + ] = mock_rpc request = {} - client.update_view(request) + client.get_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_view(request) + client.get_encryption_spec(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -16051,7 +16158,7 @@ def test_update_view_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_update_view_async_use_cached_wrapped_rpc( +async def test_get_encryption_spec_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -16068,7 +16175,7 @@ async def test_update_view_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.update_view + client._client._transport.get_encryption_spec in client._client._transport._wrapped_methods ) @@ -16076,16 +16183,16 @@ async def test_update_view_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.update_view + client._client._transport.get_encryption_spec ] = mock_rpc request = {} - await client.update_view(request) + await client.get_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.update_view(request) + await client.get_encryption_spec(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -16093,9 +16200,9 @@ async def test_update_view_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_view_async( +async def test_get_encryption_spec_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.UpdateViewRequest, + request_type=contact_center_insights.GetEncryptionSpecRequest, ): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), @@ -16107,50 +16214,52 @@ async def test_update_view_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.View( + resources.EncryptionSpec( name="name_value", - display_name="display_name_value", - value="value_value", + kms_key="kms_key_value", ) ) - response = await client.update_view(request) + response = await client.get_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = contact_center_insights.UpdateViewRequest() + request = contact_center_insights.GetEncryptionSpecRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) + assert isinstance(response, resources.EncryptionSpec) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert response.kms_key == "kms_key_value" @pytest.mark.asyncio -async def test_update_view_async_from_dict(): - await test_update_view_async(request_type=dict) +async def test_get_encryption_spec_async_from_dict(): + await test_get_encryption_spec_async(request_type=dict) -def test_update_view_field_headers(): +def test_get_encryption_spec_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateViewRequest() + request = contact_center_insights.GetEncryptionSpecRequest() - request.view.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: - call.return_value = resources.View() - client.update_view(request) + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: + call.return_value = resources.EncryptionSpec() + client.get_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -16161,26 +16270,30 @@ def test_update_view_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "view.name=name_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_view_field_headers_async(): +async def test_get_encryption_spec_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateViewRequest() + request = contact_center_insights.GetEncryptionSpecRequest() - request.view.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - await client.update_view(request) + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.EncryptionSpec() + ) + await client.get_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -16191,39 +16304,37 @@ async def test_update_view_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "view.name=name_value", + "name=name_value", ) in kw["metadata"] -def test_update_view_flattened(): +def test_get_encryption_spec_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View() + call.return_value = resources.EncryptionSpec() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_view( - view=resources.View(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_encryption_spec( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].view - mock_val = resources.View(name="name_value") - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_update_view_flattened_error(): +def test_get_encryption_spec_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -16231,46 +16342,45 @@ def test_update_view_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_view( - contact_center_insights.UpdateViewRequest(), - view=resources.View(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_encryption_spec( + contact_center_insights.GetEncryptionSpecRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_update_view_flattened_async(): +async def test_get_encryption_spec_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.View() + call.return_value = resources.EncryptionSpec() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.EncryptionSpec() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_view( - view=resources.View(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + response = await client.get_encryption_spec( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].view - mock_val = resources.View(name="name_value") - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_update_view_flattened_error_async(): +async def test_get_encryption_spec_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) @@ -16278,21 +16388,20 @@ async def test_update_view_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.update_view( - contact_center_insights.UpdateViewRequest(), - view=resources.View(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + await client.get_encryption_spec( + contact_center_insights.GetEncryptionSpecRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.DeleteViewRequest, + contact_center_insights.InitializeEncryptionSpecRequest, dict, ], ) -def test_delete_view(request_type, transport: str = "grpc"): +def test_initialize_encryption_spec(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -16303,22 +16412,24 @@ def test_delete_view(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_view(request) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.initialize_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = contact_center_insights.DeleteViewRequest() + request = contact_center_insights.InitializeEncryptionSpecRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, future.Future) -def test_delete_view_non_empty_request_with_auto_populated_field(): +def test_initialize_encryption_spec_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( @@ -16329,24 +16440,22 @@ def test_delete_view_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = contact_center_insights.DeleteViewRequest( - name="name_value", - ) + request = contact_center_insights.InitializeEncryptionSpecRequest() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.delete_view(request=request) + client.initialize_encryption_spec(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteViewRequest( - name="name_value", - ) + assert args[0] == contact_center_insights.InitializeEncryptionSpecRequest() -def test_delete_view_use_cached_wrapped_rpc(): +def test_initialize_encryption_spec_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -16360,21 +16469,31 @@ def test_delete_view_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_view in client._transport._wrapped_methods + assert ( + client._transport.initialize_encryption_spec + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_view] = mock_rpc + client._transport._wrapped_methods[ + client._transport.initialize_encryption_spec + ] = mock_rpc request = {} - client.delete_view(request) + client.initialize_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.delete_view(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.initialize_encryption_spec(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -16382,7 +16501,7 @@ def test_delete_view_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_delete_view_async_use_cached_wrapped_rpc( +async def test_initialize_encryption_spec_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -16399,7 +16518,7 @@ async def test_delete_view_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.delete_view + client._client._transport.initialize_encryption_spec in client._client._transport._wrapped_methods ) @@ -16407,16 +16526,21 @@ async def test_delete_view_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.delete_view + client._client._transport.initialize_encryption_spec ] = mock_rpc request = {} - await client.delete_view(request) + await client.initialize_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.delete_view(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.initialize_encryption_spec(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -16424,9 +16548,9 @@ async def test_delete_view_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_view_async( +async def test_initialize_encryption_spec_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.DeleteViewRequest, + request_type=contact_center_insights.InitializeEncryptionSpecRequest, ): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), @@ -16438,41 +16562,47 @@ async def test_delete_view_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_view(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.initialize_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = contact_center_insights.DeleteViewRequest() + request = contact_center_insights.InitializeEncryptionSpecRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_delete_view_async_from_dict(): - await test_delete_view_async(request_type=dict) +async def test_initialize_encryption_spec_async_from_dict(): + await test_initialize_encryption_spec_async(request_type=dict) -def test_delete_view_field_headers(): +def test_initialize_encryption_spec_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteViewRequest() + request = contact_center_insights.InitializeEncryptionSpecRequest() - request.name = "name_value" + request.encryption_spec.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: - call.return_value = None - client.delete_view(request) + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.initialize_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -16483,26 +16613,30 @@ def test_delete_view_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "encryption_spec.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_delete_view_field_headers_async(): +async def test_initialize_encryption_spec_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteViewRequest() + request = contact_center_insights.InitializeEncryptionSpecRequest() - request.name = "name_value" + request.encryption_spec.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_view(request) + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.initialize_encryption_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -16513,35 +16647,37 @@ async def test_delete_view_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "encryption_spec.name=name_value", ) in kw["metadata"] -def test_delete_view_flattened(): +def test_initialize_encryption_spec_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = None + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_view( - name="name_value", + client.initialize_encryption_spec( + encryption_spec=resources.EncryptionSpec(name="name_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].encryption_spec + mock_val = resources.EncryptionSpec(name="name_value") assert arg == mock_val -def test_delete_view_flattened_error(): +def test_initialize_encryption_spec_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -16549,41 +16685,45 @@ def test_delete_view_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_view( - contact_center_insights.DeleteViewRequest(), - name="name_value", + client.initialize_encryption_spec( + contact_center_insights.InitializeEncryptionSpecRequest(), + encryption_spec=resources.EncryptionSpec(name="name_value"), ) @pytest.mark.asyncio -async def test_delete_view_flattened_async(): +async def test_initialize_encryption_spec_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = None + call.return_value = operations_pb2.Operation(name="operations/op") - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_view( - name="name_value", + response = await client.initialize_encryption_spec( + encryption_spec=resources.EncryptionSpec(name="name_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].encryption_spec + mock_val = resources.EncryptionSpec(name="name_value") assert arg == mock_val @pytest.mark.asyncio -async def test_delete_view_flattened_error_async(): +async def test_initialize_encryption_spec_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=async_anonymous_credentials(), ) @@ -16591,19 +16731,87 @@ async def test_delete_view_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.delete_view( - contact_center_insights.DeleteViewRequest(), + await client.initialize_encryption_spec( + contact_center_insights.InitializeEncryptionSpecRequest(), + encryption_spec=resources.EncryptionSpec(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateViewRequest, + dict, + ], +) +def test_create_view(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( name="name_value", + display_name="display_name_value", + value="value_value", ) + response = client.create_view(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateViewRequest() + assert args[0] == request -def test_create_conversation_rest_use_cached_wrapped_rpc(): + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" + + +def test_create_view_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.CreateViewRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_view(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateViewRequest( + parent="parent_value", + ) + + +def test_create_view_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -16611,198 +16819,37 @@ def test_create_conversation_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.create_conversation in client._transport._wrapped_methods - ) + assert client._transport.create_view in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.create_conversation - ] = mock_rpc - + client._transport._wrapped_methods[client._transport.create_view] = mock_rpc request = {} - client.create_conversation(request) + client.create_view(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.create_conversation(request) + client.create_view(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_create_conversation_rest_required_fields( - request_type=contact_center_insights.CreateConversationRequest, +@pytest.mark.asyncio +async def test_create_view_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("conversation_id",)) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.create_conversation(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_create_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.create_conversation._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("conversationId",)) - & set( - ( - "parent", - "conversation", - ) - ) - ) - - -def test_create_conversation_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - conversation=resources.Conversation( - call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) - ), - conversation_id="conversation_id_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.create_conversation(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/conversations" - % client.transport._host, - args[1], - ) - - -def test_create_conversation_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_conversation( - contact_center_insights.CreateConversationRequest(), - parent="parent_value", - conversation=resources.Conversation( - call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) - ), - conversation_id="conversation_id_value", - ) - - -def test_upload_conversation_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) # Should wrap all calls on client creation @@ -16811,319 +16858,298 @@ def test_upload_conversation_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.upload_conversation in client._transport._wrapped_methods + client._client._transport.create_view + in client._client._transport._wrapped_methods ) # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.upload_conversation + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_view ] = mock_rpc request = {} - client.upload_conversation(request) + await client.create_view(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.upload_conversation(request) + await client.create_view(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_upload_conversation_rest_required_fields( - request_type=contact_center_insights.UploadConversationRequest, +@pytest.mark.asyncio +async def test_create_view_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.CreateViewRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).upload_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) + ) + response = await client.create_view(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateViewRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).upload_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_create_view_async_from_dict(): + await test_create_view_async(request_type=dict) + +def test_create_view_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateViewRequest() - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + request.parent = "parent_value" - response = client.upload_conversation(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + call.return_value = resources.View() + client.create_view(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_upload_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - unset_fields = transport.upload_conversation._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "conversation", - ) - ) +@pytest.mark.asyncio +async def test_create_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateViewRequest() -def test_update_conversation_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.update_conversation in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.update_conversation - ] = mock_rpc + request.parent = "parent_value" - request = {} - client.update_conversation(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.create_view(request) # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_conversation(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_update_conversation_rest_required_fields( - request_type=contact_center_insights.UpdateConversationRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +def test_create_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_view( + parent="parent_value", + view=resources.View(name="name_value"), + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) - jsonified_request.update(unset_fields) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].view + mock_val = resources.View(name="name_value") + assert arg == mock_val - # verify required fields with non-default values are left alone +def test_create_view_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_view( + contact_center_insights.CreateViewRequest(), + parent="parent_value", + view=resources.View(name="name_value"), + ) - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) +@pytest.mark.asyncio +async def test_create_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() - response = client.update_conversation(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_view( + parent="parent_value", + view=resources.View(name="name_value"), + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].view + mock_val = resources.View(name="name_value") + assert arg == mock_val -def test_update_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_create_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.update_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("conversation",))) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_view( + contact_center_insights.CreateViewRequest(), + parent="parent_value", + view=resources.View(name="name_value"), + ) -def test_update_conversation_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetViewRequest, + dict, + ], +) +def test_get_view(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - - # get arguments that satisfy an http rule for this method - sample_request = { - "conversation": { - "name": "projects/sample1/locations/sample2/conversations/sample3" - } - } + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( - conversation=resources.Conversation( - call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.get_view(request) - client.update_conversation(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetViewRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{conversation.name=projects/*/locations/*/conversations/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" -def test_update_conversation_rest_flattened_error(transport: str = "rest"): +def test_get_view_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_conversation( - contact_center_insights.UpdateConversationRequest(), - conversation=resources.Conversation( - call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.GetViewRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_view(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetViewRequest( + name="name_value", ) -def test_get_conversation_rest_use_cached_wrapped_rpc(): +def test_get_view_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -17131,181 +17157,322 @@ def test_get_conversation_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_conversation in client._transport._wrapped_methods + assert client._transport.get_view in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.get_conversation + client._transport._wrapped_methods[client._transport.get_view] = mock_rpc + request = {} + client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_view(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_view_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_view + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_view ] = mock_rpc request = {} - client.get_conversation(request) + await client.get_view(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_conversation(request) + await client.get_view(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_conversation_rest_required_fields( - request_type=contact_center_insights.GetConversationRequest, +@pytest.mark.asyncio +async def test_get_view_async( + transport: str = "grpc_asyncio", request_type=contact_center_insights.GetViewRequest ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) + ) + response = await client.get_view(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetViewRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("view",)) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_get_view_async_from_dict(): + await test_get_view_async(request_type=dict) + +def test_get_view_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetViewRequest() - # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + call.return_value = resources.View() + client.get_view(request) - response = client.get_conversation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_get_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(("view",)) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetViewRequest() + request.name = "name_value" -def test_get_conversation_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_view_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_view( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/conversations/sample3" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( + +def test_get_view_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_view( + contact_center_insights.GetViewRequest(), name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.get_conversation(**mock_args) +@pytest.mark.asyncio +async def test_get_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_view( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/conversations/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_get_conversation_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_get_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_conversation( - contact_center_insights.GetConversationRequest(), + await client.get_view( + contact_center_insights.GetViewRequest(), name="name_value", ) -def test_list_conversations_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListViewsRequest, + dict, + ], +) +def test_list_views(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListViewsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListViewsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_views_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.ListViewsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_views(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListViewsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + +def test_list_views_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -17313,447 +17480,515 @@ def test_list_conversations_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.list_conversations in client._transport._wrapped_methods - ) + assert client._transport.list_views in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.list_conversations + client._transport._wrapped_methods[client._transport.list_views] = mock_rpc + request = {} + client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_views(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_views_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.list_views + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_views ] = mock_rpc request = {} - client.list_conversations(request) + await client.list_views(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_conversations(request) + await client.list_views(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_conversations_rest_required_fields( - request_type=contact_center_insights.ListConversationsRequest, +@pytest.mark.asyncio +async def test_list_views_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.ListViewsRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListViewsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_views(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListViewsRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListViewsAsyncPager) + assert response.next_page_token == "next_page_token_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_conversations._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", - "view", - ) - ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_list_views_async_from_dict(): + await test_list_views_async(request_type=dict) + +def test_list_views_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListConversationsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListViewsRequest() - # Convert return value to protobuf type - return_value = contact_center_insights.ListConversationsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + call.return_value = contact_center_insights.ListViewsResponse() + client.list_views(request) - response = client.list_conversations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_list_conversations_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_views_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_conversations._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "orderBy", - "pageSize", - "pageToken", - "view", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListViewsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListViewsResponse() ) - & set(("parent",)) - ) + await client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_list_conversations_rest_flattened(): + +def test_list_views_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListConversationsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_views( parent="parent_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.ListConversationsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_conversations(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/conversations" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_list_conversations_rest_flattened_error(transport: str = "rest"): +def test_list_views_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_conversations( - contact_center_insights.ListConversationsRequest(), + client.list_views( + contact_center_insights.ListViewsRequest(), parent="parent_value", ) -def test_list_conversations_rest_pager(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_list_views_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - resources.Conversation(), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListViewsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_views( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_views_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_views( + contact_center_insights.ListViewsRequest(), + parent="parent_value", + ) + + +def test_list_views_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), ], next_page_token="abc", ), - contact_center_insights.ListConversationsResponse( - conversations=[], + contact_center_insights.ListViewsResponse( + views=[], next_page_token="def", ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), ], next_page_token="ghi", ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), ], ), + RuntimeError, ) - # Two responses for two calls - response = response + response - # Wrap the values into proper Response objs - response = tuple( - contact_center_insights.ListConversationsResponse.to_json(x) - for x in response + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "projects/sample1/locations/sample2"} + pager = client.list_views(request={}, retry=retry, timeout=timeout) - pager = client.list_conversations(request=sample_request) + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.Conversation) for i in results) - - pages = list(client.list_conversations(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_delete_conversation_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.delete_conversation in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.delete_conversation - ] = mock_rpc - - request = {} - client.delete_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.delete_conversation(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_conversation_rest_required_fields( - request_type=contact_center_insights.DeleteConversationRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = "name_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("force",)) - jsonified_request.update(unset_fields) + assert all(isinstance(i, resources.View) for i in results) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +def test_list_views_pages(transport_name: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport_name, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token="abc", + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token="def", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + pages = list(client.list_views(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_list_views_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response = client.delete_conversation(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token="abc", + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token="def", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_views( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + assert len(responses) == 6 + assert all(isinstance(i, resources.View) for i in responses) -def test_delete_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_views_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.delete_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(("force",)) & set(("name",))) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token="abc", + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token="def", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_views(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_delete_conversation_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateViewRequest, + dict, + ], +) +def test_update_view(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/conversations/sample3" - } + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( name="name_value", + display_name="display_name_value", + value="value_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.update_view(request) - client.delete_conversation(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateViewRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/conversations/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" -def test_delete_conversation_rest_flattened_error(transport: str = "rest"): +def test_update_view_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_conversation( - contact_center_insights.DeleteConversationRequest(), - name="name_value", + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.UpdateViewRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) + client.update_view(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateViewRequest() -def test_create_analysis_rest_use_cached_wrapped_rpc(): +def test_update_view_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -17761,365 +17996,330 @@ def test_create_analysis_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.create_analysis in client._transport._wrapped_methods + assert client._transport.update_view in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.create_analysis] = mock_rpc - + client._transport._wrapped_methods[client._transport.update_view] = mock_rpc request = {} - client.create_analysis(request) + client.update_view(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_analysis(request) + client.update_view(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_create_analysis_rest_required_fields( - request_type=contact_center_insights.CreateAnalysisRequest, +@pytest.mark.asyncio +async def test_update_view_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.update_view + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_view + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.update_view(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.update_view(request) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_update_view_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UpdateViewRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response = client.create_analysis(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) + ) + response = await client.update_view(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateViewRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" -def test_create_analysis_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - unset_fields = transport.create_analysis._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "analysis", - ) - ) - ) +@pytest.mark.asyncio +async def test_update_view_async_from_dict(): + await test_update_view_async(request_type=dict) -def test_create_analysis_rest_flattened(): +def test_update_view_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/conversations/sample3" - } + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateViewRequest() - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - analysis=resources.Analysis(name="name_value"), - ) - mock_args.update(sample_request) + request.view.name = "name_value" - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + call.return_value = resources.View() + client.update_view(request) - client.create_analysis(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" - % client.transport._host, - args[1], - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "view.name=name_value", + ) in kw["metadata"] -def test_create_analysis_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_update_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_analysis( - contact_center_insights.CreateAnalysisRequest(), - parent="parent_value", - analysis=resources.Analysis(name="name_value"), - ) - - -def test_get_analysis_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_analysis in client._transport._wrapped_methods + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateViewRequest() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.get_analysis] = mock_rpc + request.view.name = "name_value" - request = {} - client.get_analysis(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.update_view(request) # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_analysis(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "view.name=name_value", + ) in kw["metadata"] -def test_get_analysis_rest_required_fields( - request_type=contact_center_insights.GetAnalysisRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +def test_update_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = "name_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_view( + view=resources.View(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].view + mock_val = resources.View(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +def test_update_view_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.Analysis() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Analysis.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) +@pytest.mark.asyncio +async def test_update_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() - response = client.get_analysis(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_view( + view=resources.View(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].view + mock_val = resources.View(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val -def test_get_analysis_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_update_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_analysis._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) -def test_get_analysis_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteViewRequest, + dict, + ], +) +def test_delete_view(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Analysis() - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Analysis.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_view(request) - client.get_analysis(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteViewRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert response is None -def test_get_analysis_rest_flattened_error(transport: str = "rest"): +def test_delete_view_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_analysis( - contact_center_insights.GetAnalysisRequest(), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.DeleteViewRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_view(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteViewRequest( name="name_value", ) -def test_list_analyses_rest_use_cached_wrapped_rpc(): +def test_delete_view_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -18127,259 +18327,313 @@ def test_list_analyses_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_analyses in client._transport._wrapped_methods + assert client._transport.delete_view in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_analyses] = mock_rpc - + client._transport._wrapped_methods[client._transport.delete_view] = mock_rpc request = {} - client.list_analyses(request) + client.delete_view(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_analyses(request) + client.delete_view(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_analyses_rest_required_fields( - request_type=contact_center_insights.ListAnalysesRequest, +@pytest.mark.asyncio +async def test_delete_view_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.delete_view + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_analyses._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_view + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.delete_view(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_analyses._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "page_size", - "page_token", - ) + await client.delete_view(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_view_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.DeleteViewRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteViewRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + +@pytest.mark.asyncio +async def test_delete_view_async_from_dict(): + await test_delete_view_async(request_type=dict) + + +def test_delete_view_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListAnalysesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteViewRequest() - response_value = Response() - response_value.status_code = 200 + request.name = "name_value" - # Convert return value to protobuf type - return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + call.return_value = None + client.delete_view(request) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - response = client.list_analyses(request) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_delete_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteViewRequest() + + request.name = "name_value" -def test_list_analyses_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.list_analyses._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "pageSize", - "pageToken", - ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_view( + name="name_value", ) - & set(("parent",)) - ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_list_analyses_rest_flattened(): +def test_delete_view_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListAnalysesResponse() + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_view( + contact_center_insights.DeleteViewRequest(), + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/conversations/sample3" - } - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) +@pytest.mark.asyncio +async def test_delete_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None - client.list_analyses(**mock_args) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_view( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_list_analyses_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_delete_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_analyses( - contact_center_insights.ListAnalysesRequest(), - parent="parent_value", + await client.delete_view( + contact_center_insights.DeleteViewRequest(), + name="name_value", ) -def test_list_analyses_rest_pager(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.QueryMetricsRequest, + dict, + ], +) +def test_query_metrics(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - resources.Analysis(), - ], - next_page_token="abc", - ), - contact_center_insights.ListAnalysesResponse( - analyses=[], - next_page_token="def", - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - ], - next_page_token="ghi", - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - ], - ), - ) - # Two responses for two calls - response = response + response + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # Wrap the values into proper Response objs - response = tuple( - contact_center_insights.ListAnalysesResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.query_metrics(request) - sample_request = { - "parent": "projects/sample1/locations/sample2/conversations/sample3" - } + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.QueryMetricsRequest() + assert args[0] == request - pager = client.list_analyses(request=sample_request) + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Analysis) for i in results) - pages = list(client.list_analyses(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +def test_query_metrics_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.QueryMetricsRequest( + location="location_value", + filter="filter_value", + ) -def test_delete_analysis_rest_use_cached_wrapped_rpc(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.query_metrics(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.QueryMetricsRequest( + location="location_value", + filter="filter_value", + ) + + +def test_query_metrics_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -18387,172 +18641,42 @@ def test_delete_analysis_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_analysis in client._transport._wrapped_methods + assert client._transport.query_metrics in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_analysis] = mock_rpc - + client._transport._wrapped_methods[client._transport.query_metrics] = mock_rpc request = {} - client.delete_analysis(request) + client.query_metrics(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.delete_analysis(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.query_metrics(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_analysis_rest_required_fields( - request_type=contact_center_insights.DeleteAnalysisRequest, +@pytest.mark.asyncio +async def test_query_metrics_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = "name_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.delete_analysis(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_delete_analysis_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.delete_analysis._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) - - -def test_delete_analysis_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.delete_analysis(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" - % client.transport._host, - args[1], - ) - - -def test_delete_analysis_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_analysis( - contact_center_insights.DeleteAnalysisRequest(), - name="name_value", - ) - - -def test_bulk_analyze_conversations_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) # Should wrap all calls on client creation @@ -18561,200 +18685,220 @@ def test_bulk_analyze_conversations_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.bulk_analyze_conversations - in client._transport._wrapped_methods + client._client._transport.query_metrics + in client._client._transport._wrapped_methods ) # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.bulk_analyze_conversations + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.query_metrics ] = mock_rpc request = {} - client.bulk_analyze_conversations(request) + await client.query_metrics(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.bulk_analyze_conversations(request) + await client.query_metrics(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_bulk_analyze_conversations_rest_required_fields( - request_type=contact_center_insights.BulkAnalyzeConversationsRequest, +@pytest.mark.asyncio +async def test_query_metrics_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.QueryMetricsRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["filter"] = "" - request_init["analysis_percentage"] = 0.0 - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.query_metrics(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.QueryMetricsRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" - jsonified_request["filter"] = "filter_value" - jsonified_request["analysisPercentage"] = 0.20170000000000002 + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "filter" in jsonified_request - assert jsonified_request["filter"] == "filter_value" - assert "analysisPercentage" in jsonified_request - assert jsonified_request["analysisPercentage"] == 0.20170000000000002 +@pytest.mark.asyncio +async def test_query_metrics_async_from_dict(): + await test_query_metrics_async(request_type=dict) + +def test_query_metrics_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.QueryMetricsRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.location = "location_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.query_metrics(request) - response = client.bulk_analyze_conversations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "location=location_value", + ) in kw["metadata"] -def test_bulk_analyze_conversations_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_query_metrics_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.bulk_analyze_conversations._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "filter", - "analysisPercentage", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.QueryMetricsRequest() + + request.location = "location_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) - ) + await client.query_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "location=location_value", + ) in kw["metadata"] -def test_bulk_analyze_conversations_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateQaQuestionRequest, + dict, + ], +) +def test_create_qa_question(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - filter="filter_value", - analysis_percentage=0.20170000000000002, + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.create_qa_question(request) - client.bulk_analyze_conversations(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateQaQuestionRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/conversations:bulkAnalyze" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 -def test_bulk_analyze_conversations_rest_flattened_error(transport: str = "rest"): +def test_create_qa_question_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.bulk_analyze_conversations( - contact_center_insights.BulkAnalyzeConversationsRequest(), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.CreateQaQuestionRequest( + parent="parent_value", + qa_question_id="qa_question_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_qa_question(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateQaQuestionRequest( parent="parent_value", - filter="filter_value", - analysis_percentage=0.20170000000000002, + qa_question_id="qa_question_id_value", ) -def test_bulk_delete_conversations_rest_use_cached_wrapped_rpc(): +def test_create_qa_question_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -18763,8 +18907,7 @@ def test_bulk_delete_conversations_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.bulk_delete_conversations - in client._transport._wrapped_methods + client._transport.create_qa_question in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -18773,171 +18916,367 @@ def test_bulk_delete_conversations_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.bulk_delete_conversations + client._transport.create_qa_question ] = mock_rpc - request = {} - client.bulk_delete_conversations(request) + client.create_qa_question(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + client.create_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_qa_question_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() - client.bulk_delete_conversations(request) + # Ensure method has been cached + assert ( + client._client._transport.create_qa_question + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_qa_question + ] = mock_rpc + + request = {} + await client.create_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.create_qa_question(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_bulk_delete_conversations_rest_required_fields( - request_type=contact_center_insights.BulkDeleteConversationsRequest, +@pytest.mark.asyncio +async def test_create_qa_question_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.CreateQaQuestionRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).bulk_delete_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) + ) + response = await client.create_qa_question(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateQaQuestionRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).bulk_delete_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_create_qa_question_async_from_dict(): + await test_create_qa_question_async(request_type=dict) + +def test_create_qa_question_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateQaQuestionRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + call.return_value = resources.QaQuestion() + client.create_qa_question(request) - response = client.bulk_delete_conversations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_bulk_delete_conversations_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_create_qa_question_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.bulk_delete_conversations._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateQaQuestionRequest() + + request.parent = "parent_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion() + ) + await client.create_qa_question(request) -def test_bulk_delete_conversations_rest_flattened(): + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_qa_question_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_qa_question( + parent="parent_value", + qa_question=resources.QaQuestion(name="name_value"), + qa_question_id="qa_question_id_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].qa_question + mock_val = resources.QaQuestion(name="name_value") + assert arg == mock_val + arg = args[0].qa_question_id + mock_val = "qa_question_id_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( + +def test_create_qa_question_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_qa_question( + contact_center_insights.CreateQaQuestionRequest(), parent="parent_value", - filter="filter_value", + qa_question=resources.QaQuestion(name="name_value"), + qa_question_id="qa_question_id_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.bulk_delete_conversations(**mock_args) +@pytest.mark.asyncio +async def test_create_qa_question_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_qa_question( + parent="parent_value", + qa_question=resources.QaQuestion(name="name_value"), + qa_question_id="qa_question_id_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/conversations:bulkDelete" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].qa_question + mock_val = resources.QaQuestion(name="name_value") + assert arg == mock_val + arg = args[0].qa_question_id + mock_val = "qa_question_id_value" + assert arg == mock_val -def test_bulk_delete_conversations_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_create_qa_question_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.bulk_delete_conversations( - contact_center_insights.BulkDeleteConversationsRequest(), + await client.create_qa_question( + contact_center_insights.CreateQaQuestionRequest(), parent="parent_value", - filter="filter_value", + qa_question=resources.QaQuestion(name="name_value"), + qa_question_id="qa_question_id_value", ) -def test_ingest_conversations_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetQaQuestionRequest, + dict, + ], +) +def test_get_qa_question(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) + response = client.get_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetQaQuestionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 + + +def test_get_qa_question_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.GetQaQuestionRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_qa_question(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetQaQuestionRequest( + name="name_value", + ) + + +def test_get_qa_question_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -18945,179 +19284,343 @@ def test_ingest_conversations_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.ingest_conversations in client._transport._wrapped_methods - ) + assert client._transport.get_qa_question in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.ingest_conversations - ] = mock_rpc - + client._transport._wrapped_methods[client._transport.get_qa_question] = mock_rpc request = {} - client.ingest_conversations(request) + client.get_qa_question(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.ingest_conversations(request) + client.get_qa_question(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_ingest_conversations_rest_required_fields( - request_type=contact_center_insights.IngestConversationsRequest, +@pytest.mark.asyncio +async def test_get_qa_question_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.get_qa_question + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).ingest_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_qa_question + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.get_qa_question(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).ingest_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.get_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_qa_question_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.GetQaQuestionRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) + ) + response = await client.get_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetQaQuestionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 + + +@pytest.mark.asyncio +async def test_get_qa_question_async_from_dict(): + await test_get_qa_question_async(request_type=dict) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +def test_get_qa_question_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetQaQuestionRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + call.return_value = resources.QaQuestion() + client.get_qa_question(request) - response = client.ingest_conversations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_ingest_conversations_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_qa_question_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.ingest_conversations._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetQaQuestionRequest() + request.name = "name_value" -def test_ingest_conversations_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion() + ) + await client.get_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_qa_question_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_qa_question( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + +def test_get_qa_question_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_qa_question( + contact_center_insights.GetQaQuestionRequest(), + name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.ingest_conversations(**mock_args) +@pytest.mark.asyncio +async def test_get_qa_question_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_qa_question( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/conversations:ingest" - % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_qa_question_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_qa_question( + contact_center_insights.GetQaQuestionRequest(), + name="name_value", ) -def test_ingest_conversations_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateQaQuestionRequest, + dict, + ], +) +def test_update_qa_question(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.ingest_conversations( - contact_center_insights.IngestConversationsRequest(), - parent="parent_value", + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, ) + response = client.update_qa_question(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateQaQuestionRequest() + assert args[0] == request -def test_export_insights_data_rest_use_cached_wrapped_rpc(): + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 + + +def test_update_qa_question_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.UpdateQaQuestionRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_qa_question(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateQaQuestionRequest() + + +def test_update_qa_question_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -19126,7 +19629,7 @@ def test_export_insights_data_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.export_insights_data in client._transport._wrapped_methods + client._transport.update_qa_question in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -19135,359 +19638,348 @@ def test_export_insights_data_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.export_insights_data + client._transport.update_qa_question ] = mock_rpc - request = {} - client.export_insights_data(request) + client.update_qa_question(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + client.update_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_qa_question_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() - client.export_insights_data(request) + # Ensure method has been cached + assert ( + client._client._transport.update_qa_question + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_qa_question + ] = mock_rpc + + request = {} + await client.update_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.update_qa_question(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_export_insights_data_rest_required_fields( - request_type=contact_center_insights.ExportInsightsDataRequest, +@pytest.mark.asyncio +async def test_update_qa_question_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UpdateQaQuestionRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_insights_data._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) + ) + response = await client.update_qa_question(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateQaQuestionRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_insights_data._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_update_qa_question_async_from_dict(): + await test_update_qa_question_async(request_type=dict) + +def test_update_qa_question_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateQaQuestionRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.qa_question.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + call.return_value = resources.QaQuestion() + client.update_qa_question(request) - response = client.export_insights_data(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "qa_question.name=name_value", + ) in kw["metadata"] -def test_export_insights_data_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_update_qa_question_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.export_insights_data._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateQaQuestionRequest() + request.qa_question.name = "name_value" -def test_export_insights_data_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion() + ) + await client.update_qa_question(request) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "qa_question.name=name_value", + ) in kw["metadata"] - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +def test_update_qa_question_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) - client.export_insights_data(**mock_args) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_qa_question( + qa_question=resources.QaQuestion(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/insightsdata:export" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].qa_question + mock_val = resources.QaQuestion(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val -def test_export_insights_data_rest_flattened_error(transport: str = "rest"): +def test_update_qa_question_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.export_insights_data( - contact_center_insights.ExportInsightsDataRequest(), - parent="parent_value", + client.update_qa_question( + contact_center_insights.UpdateQaQuestionRequest(), + qa_question=resources.QaQuestion(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_create_issue_model_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +@pytest.mark.asyncio +async def test_update_qa_question_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaQuestion() - # Ensure method has been cached - assert ( - client._transport.create_issue_model in client._transport._wrapped_methods + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion() ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_qa_question( + qa_question=resources.QaQuestion(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - client._transport._wrapped_methods[ - client._transport.create_issue_model - ] = mock_rpc - request = {} - client.create_issue_model(request) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].qa_question + mock_val = resources.QaQuestion(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_update_qa_question_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - client.create_issue_model(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_issue_model_rest_required_fields( - request_type=contact_center_insights.CreateIssueModelRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_qa_question( + contact_center_insights.UpdateQaQuestionRequest(), + qa_question=resources.QaQuestion(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteQaQuestionRequest, + dict, + ], +) +def test_delete_qa_question(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.create_issue_model(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_qa_question(request) -def test_create_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteQaQuestionRequest() + assert args[0] == request - unset_fields = transport.create_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "issueModel", - ) - ) - ) + # Establish that the response is the type that we expect. + assert response is None -def test_create_issue_model_rest_flattened(): +def test_delete_qa_question_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - issue_model=resources.IssueModel(name="name_value"), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.create_issue_model(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/issueModels" - % client.transport._host, - args[1], - ) - - -def test_create_issue_model_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.DeleteQaQuestionRequest( + name="name_value", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_issue_model( - contact_center_insights.CreateIssueModelRequest(), - parent="parent_value", - issue_model=resources.IssueModel(name="name_value"), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_qa_question(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteQaQuestionRequest( + name="name_value", ) -def test_update_issue_model_rest_use_cached_wrapped_rpc(): +def test_delete_qa_question_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -19496,7 +19988,7 @@ def test_update_issue_model_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.update_issue_model in client._transport._wrapped_methods + client._transport.delete_qa_question in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -19505,173 +19997,324 @@ def test_update_issue_model_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_issue_model + client._transport.delete_qa_question ] = mock_rpc - request = {} - client.update_issue_model(request) + client.delete_qa_question(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_issue_model(request) + client.delete_qa_question(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_issue_model_rest_required_fields( - request_type=contact_center_insights.UpdateIssueModelRequest, +@pytest.mark.asyncio +async def test_delete_qa_question_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.delete_qa_question + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_qa_question + ] = mock_rpc + + request = {} + await client.delete_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.delete_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_qa_question_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.DeleteQaQuestionRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_qa_question(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteQaQuestionRequest() + assert args[0] == request - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_issue_model._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) - jsonified_request.update(unset_fields) + # Establish that the response is the type that we expect. + assert response is None - # verify required fields with non-default values are left alone +@pytest.mark.asyncio +async def test_delete_qa_question_async_from_dict(): + await test_delete_qa_question_async(request_type=dict) + + +def test_delete_qa_question_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteQaQuestionRequest() - # Convert return value to protobuf type - return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + call.return_value = None + client.delete_qa_question(request) - response = client.update_issue_model(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_update_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_delete_qa_question_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.update_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("issueModel",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteQaQuestionRequest() + request.name = "name_value" -def test_update_issue_model_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_qa_question_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_qa_question( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "issue_model": { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( - issue_model=resources.IssueModel(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + +def test_delete_qa_question_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_qa_question( + contact_center_insights.DeleteQaQuestionRequest(), + name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.update_issue_model(**mock_args) +@pytest.mark.asyncio +async def test_delete_qa_question_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_qa_question( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{issue_model.name=projects/*/locations/*/issueModels/*}" - % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_qa_question_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_qa_question( + contact_center_insights.DeleteQaQuestionRequest(), + name="name_value", ) -def test_update_issue_model_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListQaQuestionsRequest, + dict, + ], +) +def test_list_qa_questions(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_issue_model( - contact_center_insights.UpdateIssueModelRequest(), - issue_model=resources.IssueModel(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaQuestionsResponse( + next_page_token="next_page_token_value", ) + response = client.list_qa_questions(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListQaQuestionsRequest() + assert args[0] == request -def test_get_issue_model_rest_use_cached_wrapped_rpc(): + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQaQuestionsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_qa_questions_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.ListQaQuestionsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_qa_questions(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListQaQuestionsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + +def test_list_qa_questions_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -19679,357 +20322,547 @@ def test_get_issue_model_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_issue_model in client._transport._wrapped_methods + assert client._transport.list_qa_questions in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_issue_model] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.list_qa_questions + ] = mock_rpc request = {} - client.get_issue_model(request) + client.list_qa_questions(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_issue_model(request) + client.list_qa_questions(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_issue_model_rest_required_fields( - request_type=contact_center_insights.GetIssueModelRequest, +@pytest.mark.asyncio +async def test_list_qa_questions_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.list_qa_questions + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_qa_questions + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.list_qa_questions(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.list_qa_questions(request) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_list_qa_questions_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.ListQaQuestionsRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaQuestionsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_qa_questions(request) - # Convert return value to protobuf type - return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListQaQuestionsRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQaQuestionsAsyncPager) + assert response.next_page_token == "next_page_token_value" - response = client.get_issue_model(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_list_qa_questions_async_from_dict(): + await test_list_qa_questions_async(request_type=dict) -def test_get_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_list_qa_questions_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.get_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListQaQuestionsRequest() + request.parent = "parent_value" -def test_get_issue_model_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + call.return_value = contact_center_insights.ListQaQuestionsResponse() + client.list_qa_questions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_qa_questions_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListQaQuestionsRequest() - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } + request.parent = "parent_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaQuestionsResponse() ) - mock_args.update(sample_request) + await client.list_qa_questions(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.get_issue_model(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_qa_questions_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaQuestionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_qa_questions( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/issueModels/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_get_issue_model_rest_flattened_error(transport: str = "rest"): +def test_list_qa_questions_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_issue_model( - contact_center_insights.GetIssueModelRequest(), - name="name_value", + client.list_qa_questions( + contact_center_insights.ListQaQuestionsRequest(), + parent="parent_value", ) -def test_list_issue_models_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_list_qa_questions_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.list_issue_models in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaQuestionsResponse() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaQuestionsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_qa_questions( + parent="parent_value", ) - client._transport._wrapped_methods[ - client._transport.list_issue_models - ] = mock_rpc - - request = {} - client.list_issue_models(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - client.list_issue_models(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +@pytest.mark.asyncio +async def test_list_qa_questions_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_qa_questions( + contact_center_insights.ListQaQuestionsRequest(), + parent="parent_value", + ) -def test_list_issue_models_rest_required_fields( - request_type=contact_center_insights.ListIssueModelsRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +def test_list_qa_questions_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_issue_models._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + resources.QaQuestion(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[], + next_page_token="def", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + ], + ), + RuntimeError, + ) - # verify required fields with default values are now present + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_qa_questions(request={}, retry=retry, timeout=timeout) - jsonified_request["parent"] = "parent_value" + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_issue_models._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.QaQuestion) for i in results) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +def test_list_qa_questions_pages(transport_name: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport_name, ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssueModelsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + resources.QaQuestion(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[], + next_page_token="def", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + ], + ), + RuntimeError, + ) + pages = list(client.list_qa_questions(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Convert return value to protobuf type - return_value = contact_center_insights.ListIssueModelsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_list_qa_questions_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response = client.list_issue_models(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + resources.QaQuestion(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[], + next_page_token="def", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_qa_questions( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + assert len(responses) == 6 + assert all(isinstance(i, resources.QaQuestion) for i in responses) -def test_list_issue_models_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_qa_questions_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_issue_models._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + resources.QaQuestion(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[], + next_page_token="def", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_qa_questions(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_list_issue_models_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateQaScorecardRequest, + dict, + ], +) +def test_create_qa_scorecard(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssueModelsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.create_qa_scorecard(request) - client.list_issue_models(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateQaScorecardRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/issueModels" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" -def test_list_issue_models_rest_flattened_error(transport: str = "rest"): +def test_create_qa_scorecard_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_issue_models( - contact_center_insights.ListIssueModelsRequest(), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.CreateQaScorecardRequest( + parent="parent_value", + qa_scorecard_id="qa_scorecard_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_qa_scorecard(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateQaScorecardRequest( parent="parent_value", + qa_scorecard_id="qa_scorecard_id_value", ) -def test_delete_issue_model_rest_use_cached_wrapped_rpc(): +def test_create_qa_scorecard_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -20038,7 +20871,7 @@ def test_delete_issue_model_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.delete_issue_model in client._transport._wrapped_methods + client._transport.create_qa_scorecard in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -20047,170 +20880,355 @@ def test_delete_issue_model_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.delete_issue_model + client._transport.create_qa_scorecard ] = mock_rpc - request = {} - client.delete_issue_model(request) + client.create_qa_scorecard(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + client.create_qa_scorecard(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_qa_scorecard_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() - client.delete_issue_model(request) + # Ensure method has been cached + assert ( + client._client._transport.create_qa_scorecard + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_qa_scorecard + ] = mock_rpc + + request = {} + await client.create_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.create_qa_scorecard(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_issue_model_rest_required_fields( - request_type=contact_center_insights.DeleteIssueModelRequest, +@pytest.mark.asyncio +async def test_create_qa_scorecard_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.CreateQaScorecardRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) + ) + response = await client.create_qa_scorecard(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateQaScorecardRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_create_qa_scorecard_async_from_dict(): + await test_create_qa_scorecard_async(request_type=dict) + +def test_create_qa_scorecard_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateQaScorecardRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + call.return_value = resources.QaScorecard() + client.create_qa_scorecard(request) - response = client.delete_issue_model(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_delete_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_create_qa_scorecard_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.delete_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateQaScorecardRequest() + request.parent = "parent_value" -def test_delete_issue_model_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard() + ) + await client.create_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_qa_scorecard_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_qa_scorecard( + parent="parent_value", + qa_scorecard=resources.QaScorecard(name="name_value"), + qa_scorecard_id="qa_scorecard_id_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].qa_scorecard + mock_val = resources.QaScorecard(name="name_value") + assert arg == mock_val + arg = args[0].qa_scorecard_id + mock_val = "qa_scorecard_id_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + +def test_create_qa_scorecard_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_qa_scorecard( + contact_center_insights.CreateQaScorecardRequest(), + parent="parent_value", + qa_scorecard=resources.QaScorecard(name="name_value"), + qa_scorecard_id="qa_scorecard_id_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.delete_issue_model(**mock_args) +@pytest.mark.asyncio +async def test_create_qa_scorecard_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_qa_scorecard( + parent="parent_value", + qa_scorecard=resources.QaScorecard(name="name_value"), + qa_scorecard_id="qa_scorecard_id_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/issueModels/*}" - % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].qa_scorecard + mock_val = resources.QaScorecard(name="name_value") + assert arg == mock_val + arg = args[0].qa_scorecard_id + mock_val = "qa_scorecard_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_qa_scorecard_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_qa_scorecard( + contact_center_insights.CreateQaScorecardRequest(), + parent="parent_value", + qa_scorecard=resources.QaScorecard(name="name_value"), + qa_scorecard_id="qa_scorecard_id_value", ) -def test_delete_issue_model_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetQaScorecardRequest, + dict, + ], +) +def test_get_qa_scorecard(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_issue_model( - contact_center_insights.DeleteIssueModelRequest(), + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard( name="name_value", + display_name="display_name_value", + description="description_value", ) + response = client.get_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetQaScorecardRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" -def test_deploy_issue_model_rest_use_cached_wrapped_rpc(): + +def test_get_qa_scorecard_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.GetQaScorecardRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_qa_scorecard(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetQaScorecardRequest( + name="name_value", + ) + + +def test_get_qa_scorecard_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -20218,9 +21236,7 @@ def test_deploy_issue_model_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.deploy_issue_model in client._transport._wrapped_methods - ) + assert client._transport.get_qa_scorecard in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -20228,171 +21244,325 @@ def test_deploy_issue_model_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.deploy_issue_model + client._transport.get_qa_scorecard ] = mock_rpc - request = {} - client.deploy_issue_model(request) + client.get_qa_scorecard(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + client.get_qa_scorecard(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_qa_scorecard_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() - client.deploy_issue_model(request) + # Ensure method has been cached + assert ( + client._client._transport.get_qa_scorecard + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_qa_scorecard + ] = mock_rpc + + request = {} + await client.get_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_qa_scorecard(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_deploy_issue_model_rest_required_fields( - request_type=contact_center_insights.DeployIssueModelRequest, +@pytest.mark.asyncio +async def test_get_qa_scorecard_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.GetQaScorecardRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).deploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) + ) + response = await client.get_qa_scorecard(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetQaScorecardRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).deploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_get_qa_scorecard_async_from_dict(): + await test_get_qa_scorecard_async(request_type=dict) + +def test_get_qa_scorecard_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetQaScorecardRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + call.return_value = resources.QaScorecard() + client.get_qa_scorecard(request) - response = client.deploy_issue_model(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_deploy_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_qa_scorecard_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.deploy_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetQaScorecardRequest() + request.name = "name_value" -def test_deploy_issue_model_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard() + ) + await client.get_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_qa_scorecard_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_qa_scorecard( name="name_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.deploy_issue_model(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/issueModels/*}:deploy" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_deploy_issue_model_rest_flattened_error(transport: str = "rest"): +def test_get_qa_scorecard_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.deploy_issue_model( - contact_center_insights.DeployIssueModelRequest(), + client.get_qa_scorecard( + contact_center_insights.GetQaScorecardRequest(), name="name_value", ) -def test_undeploy_issue_model_rest_use_cached_wrapped_rpc(): +@pytest.mark.asyncio +async def test_get_qa_scorecard_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_qa_scorecard( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_qa_scorecard_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_qa_scorecard( + contact_center_insights.GetQaScorecardRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateQaScorecardRequest, + dict, + ], +) +def test_update_qa_scorecard(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) + response = client.update_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateQaScorecardRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + + +def test_update_qa_scorecard_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.UpdateQaScorecardRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_qa_scorecard(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateQaScorecardRequest() + + +def test_update_qa_scorecard_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -20401,7 +21571,7 @@ def test_undeploy_issue_model_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.undeploy_issue_model in client._transport._wrapped_methods + client._transport.update_qa_scorecard in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -20410,171 +21580,342 @@ def test_undeploy_issue_model_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.undeploy_issue_model + client._transport.update_qa_scorecard ] = mock_rpc - request = {} - client.undeploy_issue_model(request) + client.update_qa_scorecard(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + client.update_qa_scorecard(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_qa_scorecard_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() - client.undeploy_issue_model(request) + # Ensure method has been cached + assert ( + client._client._transport.update_qa_scorecard + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_qa_scorecard + ] = mock_rpc + + request = {} + await client.update_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.update_qa_scorecard(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_undeploy_issue_model_rest_required_fields( - request_type=contact_center_insights.UndeployIssueModelRequest, +@pytest.mark.asyncio +async def test_update_qa_scorecard_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UpdateQaScorecardRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).undeploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) + ) + response = await client.update_qa_scorecard(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateQaScorecardRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).undeploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_update_qa_scorecard_async_from_dict(): + await test_update_qa_scorecard_async(request_type=dict) + +def test_update_qa_scorecard_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateQaScorecardRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.qa_scorecard.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + call.return_value = resources.QaScorecard() + client.update_qa_scorecard(request) - response = client.undeploy_issue_model(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "qa_scorecard.name=name_value", + ) in kw["metadata"] -def test_undeploy_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_update_qa_scorecard_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.undeploy_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateQaScorecardRequest() + request.qa_scorecard.name = "name_value" -def test_undeploy_issue_model_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard() + ) + await client.update_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "qa_scorecard.name=name_value", + ) in kw["metadata"] + + +def test_update_qa_scorecard_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_qa_scorecard( + qa_scorecard=resources.QaScorecard(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].qa_scorecard + mock_val = resources.QaScorecard(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + +def test_update_qa_scorecard_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_qa_scorecard( + contact_center_insights.UpdateQaScorecardRequest(), + qa_scorecard=resources.QaScorecard(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.undeploy_issue_model(**mock_args) +@pytest.mark.asyncio +async def test_update_qa_scorecard_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecard() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_qa_scorecard( + qa_scorecard=resources.QaScorecard(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/issueModels/*}:undeploy" - % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].qa_scorecard + mock_val = resources.QaScorecard(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_qa_scorecard_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_qa_scorecard( + contact_center_insights.UpdateQaScorecardRequest(), + qa_scorecard=resources.QaScorecard(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_undeploy_issue_model_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteQaScorecardRequest, + dict, + ], +) +def test_delete_qa_scorecard(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.undeploy_issue_model( - contact_center_insights.UndeployIssueModelRequest(), + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteQaScorecardRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_qa_scorecard_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.DeleteQaScorecardRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_qa_scorecard(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteQaScorecardRequest( name="name_value", ) -def test_export_issue_model_rest_use_cached_wrapped_rpc(): +def test_delete_qa_scorecard_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -20583,7 +21924,7 @@ def test_export_issue_model_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.export_issue_model in client._transport._wrapped_methods + client._transport.delete_qa_scorecard in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -20592,171 +21933,324 @@ def test_export_issue_model_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.export_issue_model + client._transport.delete_qa_scorecard ] = mock_rpc - request = {} - client.export_issue_model(request) + client.delete_qa_scorecard(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.export_issue_model(request) + client.delete_qa_scorecard(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_export_issue_model_rest_required_fields( - request_type=contact_center_insights.ExportIssueModelRequest, +@pytest.mark.asyncio +async def test_delete_qa_scorecard_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.delete_qa_scorecard + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_qa_scorecard + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.delete_qa_scorecard(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.delete_qa_scorecard(request) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_delete_qa_scorecard_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.DeleteQaScorecardRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_qa_scorecard(request) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteQaScorecardRequest() + assert args[0] == request - response = client.export_issue_model(request) + # Establish that the response is the type that we expect. + assert response is None - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_delete_qa_scorecard_async_from_dict(): + await test_delete_qa_scorecard_async(request_type=dict) -def test_export_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials + +def test_delete_qa_scorecard_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.export_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteQaScorecardRequest() + request.name = "name_value" -def test_export_issue_model_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + call.return_value = None + client.delete_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_qa_scorecard_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteQaScorecardRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_qa_scorecard_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_qa_scorecard( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( + +def test_delete_qa_scorecard_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_qa_scorecard( + contact_center_insights.DeleteQaScorecardRequest(), name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.export_issue_model(**mock_args) +@pytest.mark.asyncio +async def test_delete_qa_scorecard_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_qa_scorecard( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/issueModels/*}:export" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_export_issue_model_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_delete_qa_scorecard_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.export_issue_model( - contact_center_insights.ExportIssueModelRequest(), + await client.delete_qa_scorecard( + contact_center_insights.DeleteQaScorecardRequest(), name="name_value", ) -def test_import_issue_model_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListQaScorecardsRequest, + dict, + ], +) +def test_list_qa_scorecards(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaScorecardsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_qa_scorecards(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListQaScorecardsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQaScorecardsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_qa_scorecards_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.ListQaScorecardsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_qa_scorecards(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListQaScorecardsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + +def test_list_qa_scorecards_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -20765,7 +22259,7 @@ def test_import_issue_model_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.import_issue_model in client._transport._wrapped_methods + client._transport.list_qa_scorecards in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -20774,347 +22268,539 @@ def test_import_issue_model_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.import_issue_model + client._transport.list_qa_scorecards ] = mock_rpc - request = {} - client.import_issue_model(request) + client.list_qa_scorecards(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + client.list_qa_scorecards(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_qa_scorecards_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() - client.import_issue_model(request) + # Ensure method has been cached + assert ( + client._client._transport.list_qa_scorecards + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_qa_scorecards + ] = mock_rpc + + request = {} + await client.list_qa_scorecards(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_qa_scorecards(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_import_issue_model_rest_required_fields( - request_type=contact_center_insights.ImportIssueModelRequest, +@pytest.mark.asyncio +async def test_list_qa_scorecards_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.ListQaScorecardsRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).import_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_qa_scorecards(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListQaScorecardsRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQaScorecardsAsyncPager) + assert response.next_page_token == "next_page_token_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).import_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_list_qa_scorecards_async_from_dict(): + await test_list_qa_scorecards_async(request_type=dict) + +def test_list_qa_scorecards_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListQaScorecardsRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + call.return_value = contact_center_insights.ListQaScorecardsResponse() + client.list_qa_scorecards(request) - response = client.import_issue_model(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_import_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_qa_scorecards_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.import_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListQaScorecardsRequest() + request.parent = "parent_value" -def test_import_issue_model_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardsResponse() + ) + await client.list_qa_scorecards(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_qa_scorecards_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaScorecardsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_qa_scorecards( parent="parent_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.import_issue_model(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/issueModels:import" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_import_issue_model_rest_flattened_error(transport: str = "rest"): +def test_list_qa_scorecards_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.import_issue_model( - contact_center_insights.ImportIssueModelRequest(), + client.list_qa_scorecards( + contact_center_insights.ListQaScorecardsRequest(), parent="parent_value", ) -def test_get_issue_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_list_qa_scorecards_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.get_issue in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaScorecardsResponse() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_qa_scorecards( + parent="parent_value", ) - client._transport._wrapped_methods[client._transport.get_issue] = mock_rpc - - request = {} - client.get_issue(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - client.get_issue(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +@pytest.mark.asyncio +async def test_list_qa_scorecards_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_qa_scorecards( + contact_center_insights.ListQaScorecardsRequest(), + parent="parent_value", + ) -def test_get_issue_rest_required_fields( - request_type=contact_center_insights.GetIssueRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +def test_list_qa_scorecards_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, ) - # verify fields with default values are dropped + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + resources.QaScorecard(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + ], + ), + RuntimeError, + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_qa_scorecards(request={}, retry=retry, timeout=timeout) - # verify required fields with default values are now present + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout - jsonified_request["name"] = "name_value" + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.QaScorecard) for i in results) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +def test_list_qa_scorecards_pages(transport_name: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport_name, ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Issue() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + resources.QaScorecard(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + ], + ), + RuntimeError, + ) + pages = list(client.list_qa_scorecards(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Convert return value to protobuf type - return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_list_qa_scorecards_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response = client.get_issue(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + resources.QaScorecard(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_qa_scorecards( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + assert len(responses) == 6 + assert all(isinstance(i, resources.QaScorecard) for i in responses) -def test_get_issue_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_qa_scorecards_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_issue._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + resources.QaScorecard(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_qa_scorecards(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_get_issue_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateQaScorecardRevisionRequest, + dict, + ], +) +def test_create_qa_scorecard_revision(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Issue() - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" - } + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision( name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.create_qa_scorecard_revision(request) - client.get_issue(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateQaScorecardRevisionRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE -def test_get_issue_rest_flattened_error(transport: str = "rest"): +def test_create_qa_scorecard_revision_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_issue( - contact_center_insights.GetIssueRequest(), - name="name_value", + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.CreateQaScorecardRevisionRequest( + parent="parent_value", + qa_scorecard_revision_id="qa_scorecard_revision_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_qa_scorecard_revision(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateQaScorecardRevisionRequest( + parent="parent_value", + qa_scorecard_revision_id="qa_scorecard_revision_id_value", ) -def test_list_issues_rest_use_cached_wrapped_rpc(): +def test_create_qa_scorecard_revision_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -21122,357 +22808,413 @@ def test_list_issues_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_issues in client._transport._wrapped_methods + assert ( + client._transport.create_qa_scorecard_revision + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_issues] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.create_qa_scorecard_revision + ] = mock_rpc request = {} - client.list_issues(request) + client.create_qa_scorecard_revision(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_issues(request) + client.create_qa_scorecard_revision(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_issues_rest_required_fields( - request_type=contact_center_insights.ListIssuesRequest, +@pytest.mark.asyncio +async def test_create_qa_scorecard_revision_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.create_qa_scorecard_revision + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_qa_scorecard_revision + ] = mock_rpc + + request = {} + await client.create_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.create_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_qa_scorecard_revision_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.CreateQaScorecardRevisionRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_issues._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + ) + response = await client.create_qa_scorecard_revision(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateQaScorecardRevisionRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_issues._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_create_qa_scorecard_revision_async_from_dict(): + await test_create_qa_scorecard_revision_async(request_type=dict) + +def test_create_qa_scorecard_revision_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssuesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateQaScorecardRevisionRequest() - # Convert return value to protobuf type - return_value = contact_center_insights.ListIssuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.create_qa_scorecard_revision(request) - response = client.list_issues(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_list_issues_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_create_qa_scorecard_revision_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_issues._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateQaScorecardRevisionRequest() + request.parent = "parent_value" -def test_list_issues_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision() + ) + await client.create_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_qa_scorecard_revision_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssuesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/issueModels/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_qa_scorecard_revision( parent="parent_value", + qa_scorecard_revision=resources.QaScorecardRevision(name="name_value"), + qa_scorecard_revision_id="qa_scorecard_revision_id_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.ListIssuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_issues(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/issueModels/*}/issues" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].qa_scorecard_revision + mock_val = resources.QaScorecardRevision(name="name_value") + assert arg == mock_val + arg = args[0].qa_scorecard_revision_id + mock_val = "qa_scorecard_revision_id_value" + assert arg == mock_val -def test_list_issues_rest_flattened_error(transport: str = "rest"): +def test_create_qa_scorecard_revision_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_issues( - contact_center_insights.ListIssuesRequest(), + client.create_qa_scorecard_revision( + contact_center_insights.CreateQaScorecardRevisionRequest(), parent="parent_value", + qa_scorecard_revision=resources.QaScorecardRevision(name="name_value"), + qa_scorecard_revision_id="qa_scorecard_revision_id_value", ) -def test_update_issue_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_create_qa_scorecard_revision_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.update_issue in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_qa_scorecard_revision( + parent="parent_value", + qa_scorecard_revision=resources.QaScorecardRevision(name="name_value"), + qa_scorecard_revision_id="qa_scorecard_revision_id_value", ) - client._transport._wrapped_methods[client._transport.update_issue] = mock_rpc - - request = {} - client.update_issue(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].qa_scorecard_revision + mock_val = resources.QaScorecardRevision(name="name_value") + assert arg == mock_val + arg = args[0].qa_scorecard_revision_id + mock_val = "qa_scorecard_revision_id_value" + assert arg == mock_val - client.update_issue(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +@pytest.mark.asyncio +async def test_create_qa_scorecard_revision_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_qa_scorecard_revision( + contact_center_insights.CreateQaScorecardRevisionRequest(), + parent="parent_value", + qa_scorecard_revision=resources.QaScorecardRevision(name="name_value"), + qa_scorecard_revision_id="qa_scorecard_revision_id_value", + ) -def test_update_issue_rest_required_fields( - request_type=contact_center_insights.UpdateIssueRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetQaScorecardRevisionRequest, + dict, + ], +) +def test_get_qa_scorecard_revision(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # verify required fields with default values are now present + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + response = client.get_qa_scorecard_revision(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_issue._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) - jsonified_request.update(unset_fields) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetQaScorecardRevisionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE - # verify required fields with non-default values are left alone +def test_get_qa_scorecard_revision_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Issue() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.update_issue(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_update_issue_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials + transport="grpc", ) - unset_fields = transport.update_issue._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("issue",))) - - -def test_update_issue_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.GetQaScorecardRevisionRequest( + name="name_value", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Issue() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_qa_scorecard_revision(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetQaScorecardRevisionRequest( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "issue": { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" - } - } - # get truthy value for each flattened field - mock_args = dict( - issue=resources.Issue(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), +def test_get_qa_scorecard_revision_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - client.update_issue(**mock_args) + # Ensure method has been cached + assert ( + client._transport.get_qa_scorecard_revision + in client._transport._wrapped_methods + ) - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}" - % client.transport._host, - args[1], + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) + client._transport._wrapped_methods[ + client._transport.get_qa_scorecard_revision + ] = mock_rpc + request = {} + client.get_qa_scorecard_revision(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -def test_update_issue_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) + client.get_qa_scorecard_revision(request) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_issue( - contact_center_insights.UpdateIssueRequest(), - issue=resources.Issue(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -def test_delete_issue_rest_use_cached_wrapped_rpc(): +@pytest.mark.asyncio +async def test_get_qa_scorecard_revision_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) # Should wrap all calls on client creation @@ -21480,172 +23222,302 @@ def test_delete_issue_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_issue in client._transport._wrapped_methods + assert ( + client._client._transport.get_qa_scorecard_revision + in client._client._transport._wrapped_methods + ) # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.delete_issue] = mock_rpc + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_qa_scorecard_revision + ] = mock_rpc request = {} - client.delete_issue(request) + await client.get_qa_scorecard_revision(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.delete_issue(request) + await client.get_qa_scorecard_revision(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_issue_rest_required_fields( - request_type=contact_center_insights.DeleteIssueRequest, +@pytest.mark.asyncio +async def test_get_qa_scorecard_revision_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.GetQaScorecardRevisionRequest, ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + ) + response = await client.get_qa_scorecard_revision(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetQaScorecardRevisionRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_get_qa_scorecard_revision_async_from_dict(): + await test_get_qa_scorecard_revision_async(request_type=dict) + +def test_get_qa_scorecard_revision_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetQaScorecardRevisionRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = "" + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.get_qa_scorecard_revision(request) - response = client.delete_issue(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_delete_issue_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_qa_scorecard_revision_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.delete_issue._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetQaScorecardRevisionRequest() + + request.name = "name_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision() + ) + await client.get_qa_scorecard_revision(request) -def test_delete_issue_rest_flattened(): + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_qa_scorecard_revision_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_qa_scorecard_revision( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( + +def test_get_qa_scorecard_revision_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_qa_scorecard_revision( + contact_center_insights.GetQaScorecardRevisionRequest(), name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.delete_issue(**mock_args) +@pytest.mark.asyncio +async def test_get_qa_scorecard_revision_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_qa_scorecard_revision( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_delete_issue_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_get_qa_scorecard_revision_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_issue( - contact_center_insights.DeleteIssueRequest(), + await client.get_qa_scorecard_revision( + contact_center_insights.GetQaScorecardRevisionRequest(), name="name_value", ) -def test_calculate_issue_model_stats_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.TuneQaScorecardRevisionRequest, + dict, + ], +) +def test_tune_qa_scorecard_revision(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.tune_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.TuneQaScorecardRevisionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_tune_qa_scorecard_revision_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.TuneQaScorecardRevisionRequest( + parent="parent_value", + filter="filter_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.tune_qa_scorecard_revision(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.TuneQaScorecardRevisionRequest( + parent="parent_value", + filter="filter_value", + ) + + +def test_tune_qa_scorecard_revision_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -21654,7 +23526,7 @@ def test_calculate_issue_model_stats_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.calculate_issue_model_stats + client._transport.tune_qa_scorecard_revision in client._transport._wrapped_methods ) @@ -21664,367 +23536,362 @@ def test_calculate_issue_model_stats_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.calculate_issue_model_stats + client._transport.tune_qa_scorecard_revision ] = mock_rpc - request = {} - client.calculate_issue_model_stats(request) + client.tune_qa_scorecard_revision(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.calculate_issue_model_stats(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.tune_qa_scorecard_revision(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_calculate_issue_model_stats_rest_required_fields( - request_type=contact_center_insights.CalculateIssueModelStatsRequest, +@pytest.mark.asyncio +async def test_tune_qa_scorecard_revision_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["issue_model"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.tune_qa_scorecard_revision + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.tune_qa_scorecard_revision + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.tune_qa_scorecard_revision(request) - jsonified_request["issueModel"] = "issue_model_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # verify required fields with non-default values are left alone - assert "issueModel" in jsonified_request - assert jsonified_request["issueModel"] == "issue_model_value" + await client.tune_qa_scorecard_revision(request) - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateIssueModelStatsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) +@pytest.mark.asyncio +async def test_tune_qa_scorecard_revision_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.TuneQaScorecardRevisionRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response = client.calculate_issue_model_stats(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.tune_qa_scorecard_revision(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.TuneQaScorecardRevisionRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -def test_calculate_issue_model_stats_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - unset_fields = transport.calculate_issue_model_stats._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("issueModel",))) +@pytest.mark.asyncio +async def test_tune_qa_scorecard_revision_async_from_dict(): + await test_tune_qa_scorecard_revision_async(request_type=dict) -def test_calculate_issue_model_stats_rest_flattened(): +def test_tune_qa_scorecard_revision_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateIssueModelStatsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "issue_model": "projects/sample1/locations/sample2/issueModels/sample3" - } + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.TuneQaScorecardRevisionRequest() - # get truthy value for each flattened field - mock_args = dict( - issue_model="issue_model_value", - ) - mock_args.update(sample_request) + request.parent = "parent_value" - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.tune_qa_scorecard_revision(request) - client.calculate_issue_model_stats(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats" - % client.transport._host, - args[1], - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_calculate_issue_model_stats_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_tune_qa_scorecard_revision_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.calculate_issue_model_stats( - contact_center_insights.CalculateIssueModelStatsRequest(), - issue_model="issue_model_value", - ) - - -def test_create_phrase_matcher_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.TuneQaScorecardRevisionRequest() - # Ensure method has been cached - assert ( - client._transport.create_phrase_matcher - in client._transport._wrapped_methods - ) + request.parent = "parent_value" - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) - client._transport._wrapped_methods[ - client._transport.create_phrase_matcher - ] = mock_rpc - - request = {} - client.create_phrase_matcher(request) + await client.tune_qa_scorecard_revision(request) # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_phrase_matcher(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_create_phrase_matcher_rest_required_fields( - request_type=contact_center_insights.CreatePhraseMatcherRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +def test_tune_qa_scorecard_revision_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.tune_qa_scorecard_revision( + parent="parent_value", + filter="filter_value", + validate_only=True, + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].filter + mock_val = "filter_value" + assert arg == mock_val + arg = args[0].validate_only + mock_val = True + assert arg == mock_val - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +def test_tune_qa_scorecard_revision_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.tune_qa_scorecard_revision( + contact_center_insights.TuneQaScorecardRevisionRequest(), + parent="parent_value", + filter="filter_value", + validate_only=True, + ) - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) +@pytest.mark.asyncio +async def test_tune_qa_scorecard_revision_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") - response = client.create_phrase_matcher(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.tune_qa_scorecard_revision( + parent="parent_value", + filter="filter_value", + validate_only=True, + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].filter + mock_val = "filter_value" + assert arg == mock_val + arg = args[0].validate_only + mock_val = True + assert arg == mock_val -def test_create_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_tune_qa_scorecard_revision_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.create_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "phraseMatcher", - ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.tune_qa_scorecard_revision( + contact_center_insights.TuneQaScorecardRevisionRequest(), + parent="parent_value", + filter="filter_value", + validate_only=True, ) - ) -def test_create_phrase_matcher_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeployQaScorecardRevisionRequest, + dict, + ], +) +def test_deploy_qa_scorecard_revision(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - phrase_matcher=resources.PhraseMatcher(name="name_value"), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.deploy_qa_scorecard_revision(request) - client.create_phrase_matcher(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeployQaScorecardRevisionRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/phraseMatchers" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE -def test_create_phrase_matcher_rest_flattened_error(transport: str = "rest"): +def test_deploy_qa_scorecard_revision_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_phrase_matcher( - contact_center_insights.CreatePhraseMatcherRequest(), - parent="parent_value", - phrase_matcher=resources.PhraseMatcher(name="name_value"), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.DeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.deploy_qa_scorecard_revision(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployQaScorecardRevisionRequest( + name="name_value", ) -def test_get_phrase_matcher_rest_use_cached_wrapped_rpc(): +def test_deploy_qa_scorecard_revision_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -22033,7 +23900,8 @@ def test_get_phrase_matcher_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.get_phrase_matcher in client._transport._wrapped_methods + client._transport.deploy_qa_scorecard_revision + in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -22042,171 +23910,253 @@ def test_get_phrase_matcher_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_phrase_matcher + client._transport.deploy_qa_scorecard_revision ] = mock_rpc - request = {} - client.get_phrase_matcher(request) + client.deploy_qa_scorecard_revision(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_phrase_matcher(request) + client.deploy_qa_scorecard_revision(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_phrase_matcher_rest_required_fields( - request_type=contact_center_insights.GetPhraseMatcherRequest, +@pytest.mark.asyncio +async def test_deploy_qa_scorecard_revision_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.deploy_qa_scorecard_revision + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.deploy_qa_scorecard_revision + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.deploy_qa_scorecard_revision(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.deploy_qa_scorecard_revision(request) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_deploy_qa_scorecard_revision_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.DeployQaScorecardRevisionRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + ) + response = await client.deploy_qa_scorecard_revision(request) - # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeployQaScorecardRevisionRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE - response = client.get_phrase_matcher(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_deploy_qa_scorecard_revision_async_from_dict(): + await test_deploy_qa_scorecard_revision_async(request_type=dict) -def test_get_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_deploy_qa_scorecard_revision_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.get_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeployQaScorecardRevisionRequest() + request.name = "name_value" -def test_get_phrase_matcher_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.deploy_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_deploy_qa_scorecard_revision_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeployQaScorecardRevisionRequest() - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" - } + request.name = "name_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision() ) - mock_args.update(sample_request) + await client.deploy_qa_scorecard_revision(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.get_phrase_matcher(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" - % client.transport._host, - args[1], + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UndeployQaScorecardRevisionRequest, + dict, + ], +) +def test_undeploy_qa_scorecard_revision(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, ) + response = client.undeploy_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UndeployQaScorecardRevisionRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE -def test_get_phrase_matcher_rest_flattened_error(transport: str = "rest"): + +def test_undeploy_qa_scorecard_revision_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_phrase_matcher( - contact_center_insights.GetPhraseMatcherRequest(), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.UndeployQaScorecardRevisionRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.undeploy_qa_scorecard_revision(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UndeployQaScorecardRevisionRequest( name="name_value", ) -def test_list_phrase_matchers_rest_use_cached_wrapped_rpc(): +def test_undeploy_qa_scorecard_revision_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -22215,7 +24165,8 @@ def test_list_phrase_matchers_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.list_phrase_matchers in client._transport._wrapped_methods + client._transport.undeploy_qa_scorecard_revision + in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -22224,254 +24175,246 @@ def test_list_phrase_matchers_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.list_phrase_matchers + client._transport.undeploy_qa_scorecard_revision ] = mock_rpc - request = {} - client.list_phrase_matchers(request) + client.undeploy_qa_scorecard_revision(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_phrase_matchers(request) + client.undeploy_qa_scorecard_revision(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_phrase_matchers_rest_required_fields( - request_type=contact_center_insights.ListPhraseMatchersRequest, +@pytest.mark.asyncio +async def test_undeploy_qa_scorecard_revision_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.undeploy_qa_scorecard_revision + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_phrase_matchers._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.undeploy_qa_scorecard_revision + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.undeploy_qa_scorecard_revision(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_phrase_matchers._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) + await client.undeploy_qa_scorecard_revision(request) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListPhraseMatchersResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result +@pytest.mark.asyncio +async def test_undeploy_qa_scorecard_revision_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UndeployQaScorecardRevisionRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - response_value = Response() - response_value.status_code = 200 + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # Convert return value to protobuf type - return_value = contact_center_insights.ListPhraseMatchersResponse.pb( - return_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, ) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.list_phrase_matchers(request) + ) + response = await client.undeploy_qa_scorecard_revision(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UndeployQaScorecardRevisionRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE -def test_list_phrase_matchers_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - unset_fields = transport.list_phrase_matchers._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) +@pytest.mark.asyncio +async def test_undeploy_qa_scorecard_revision_async_from_dict(): + await test_undeploy_qa_scorecard_revision_async(request_type=dict) -def test_list_phrase_matchers_rest_flattened(): +def test_undeploy_qa_scorecard_revision_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListPhraseMatchersResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UndeployQaScorecardRevisionRequest() - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) + request.name = "name_value" - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.ListPhraseMatchersResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.undeploy_qa_scorecard_revision(request) - client.list_phrase_matchers(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/phraseMatchers" - % client.transport._host, - args[1], - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_list_phrase_matchers_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_undeploy_qa_scorecard_revision_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_phrase_matchers( - contact_center_insights.ListPhraseMatchersRequest(), - parent="parent_value", + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UndeployQaScorecardRevisionRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision() ) + await client.undeploy_qa_scorecard_revision(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_list_phrase_matchers_rest_pager(transport: str = "rest"): + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteQaScorecardRevisionRequest, + dict, + ], +) +def test_delete_qa_scorecard_revision(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - next_page_token="abc", - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[], - next_page_token="def", - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - ], - next_page_token="ghi", - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - ), - ) - # Two responses for two calls - response = response + response + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # Wrap the values into proper Response objs - response = tuple( - contact_center_insights.ListPhraseMatchersResponse.to_json(x) - for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_qa_scorecard_revision(request) - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteQaScorecardRevisionRequest() + assert args[0] == request - pager = client.list_phrase_matchers(request=sample_request) + # Establish that the response is the type that we expect. + assert response is None - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.PhraseMatcher) for i in results) - pages = list(client.list_phrase_matchers(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +def test_delete_qa_scorecard_revision_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.DeleteQaScorecardRevisionRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_qa_scorecard_revision(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteQaScorecardRevisionRequest( + name="name_value", + ) -def test_delete_phrase_matcher_rest_use_cached_wrapped_rpc(): +def test_delete_qa_scorecard_revision_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -22480,7 +24423,7 @@ def test_delete_phrase_matcher_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.delete_phrase_matcher + client._transport.delete_qa_scorecard_revision in client._transport._wrapped_methods ) @@ -22490,166 +24433,326 @@ def test_delete_phrase_matcher_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.delete_phrase_matcher + client._transport.delete_qa_scorecard_revision ] = mock_rpc - request = {} - client.delete_phrase_matcher(request) + client.delete_qa_scorecard_revision(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.delete_phrase_matcher(request) + client.delete_qa_scorecard_revision(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_phrase_matcher_rest_required_fields( - request_type=contact_center_insights.DeletePhraseMatcherRequest, +@pytest.mark.asyncio +async def test_delete_qa_scorecard_revision_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.delete_qa_scorecard_revision + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_qa_scorecard_revision + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.delete_qa_scorecard_revision(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.delete_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_qa_scorecard_revision_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.DeleteQaScorecardRevisionRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteQaScorecardRevisionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_qa_scorecard_revision_async_from_dict(): + await test_delete_qa_scorecard_revision_async(request_type=dict) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +def test_delete_qa_scorecard_revision_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteQaScorecardRevisionRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = "" + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = None + client.delete_qa_scorecard_revision(request) - response = client.delete_phrase_matcher(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_delete_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_delete_qa_scorecard_revision_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.delete_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteQaScorecardRevisionRequest() + + request.name = "name_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_qa_scorecard_revision(request) -def test_delete_phrase_matcher_rest_flattened(): + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_qa_scorecard_revision_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_qa_scorecard_revision( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( + +def test_delete_qa_scorecard_revision_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_qa_scorecard_revision( + contact_center_insights.DeleteQaScorecardRevisionRequest(), name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.delete_phrase_matcher(**mock_args) +@pytest.mark.asyncio +async def test_delete_qa_scorecard_revision_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_qa_scorecard_revision( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_delete_phrase_matcher_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_delete_qa_scorecard_revision_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_phrase_matcher( - contact_center_insights.DeletePhraseMatcherRequest(), + await client.delete_qa_scorecard_revision( + contact_center_insights.DeleteQaScorecardRevisionRequest(), name="name_value", ) -def test_update_phrase_matcher_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListQaScorecardRevisionsRequest, + dict, + ], +) +def test_list_qa_scorecard_revisions(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaScorecardRevisionsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_qa_scorecard_revisions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListQaScorecardRevisionsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQaScorecardRevisionsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_qa_scorecard_revisions_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.ListQaScorecardRevisionsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_qa_scorecard_revisions(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListQaScorecardRevisionsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + ) + + +def test_list_qa_scorecard_revisions_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -22658,7 +24761,7 @@ def test_update_phrase_matcher_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.update_phrase_matcher + client._transport.list_qa_scorecard_revisions in client._transport._wrapped_methods ) @@ -22668,353 +24771,540 @@ def test_update_phrase_matcher_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_phrase_matcher + client._transport.list_qa_scorecard_revisions ] = mock_rpc - request = {} - client.update_phrase_matcher(request) + client.list_qa_scorecard_revisions(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_phrase_matcher(request) + client.list_qa_scorecard_revisions(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_phrase_matcher_rest_required_fields( - request_type=contact_center_insights.UpdatePhraseMatcherRequest, +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.list_qa_scorecard_revisions + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_qa_scorecard_revisions + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.list_qa_scorecard_revisions(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_phrase_matcher._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) - jsonified_request.update(unset_fields) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # verify required fields with non-default values are left alone + await client.list_qa_scorecard_revisions(request) - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.ListQaScorecardRevisionsRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardRevisionsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_qa_scorecard_revisions(request) - # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListQaScorecardRevisionsRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQaScorecardRevisionsAsyncPager) + assert response.next_page_token == "next_page_token_value" - response = client.update_phrase_matcher(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_async_from_dict(): + await test_list_qa_scorecard_revisions_async(request_type=dict) -def test_update_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_list_qa_scorecard_revisions_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.update_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("phraseMatcher",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListQaScorecardRevisionsRequest() + request.parent = "parent_value" -def test_update_phrase_matcher_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + call.return_value = contact_center_insights.ListQaScorecardRevisionsResponse() + client.list_qa_scorecard_revisions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListQaScorecardRevisionsRequest() - # get arguments that satisfy an http rule for this method - sample_request = { - "phrase_matcher": { - "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" - } - } + request.parent = "parent_value" - # get truthy value for each flattened field - mock_args = dict( - phrase_matcher=resources.PhraseMatcher(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardRevisionsResponse() ) - mock_args.update(sample_request) + await client.list_qa_scorecard_revisions(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.update_phrase_matcher(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_qa_scorecard_revisions_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaScorecardRevisionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_qa_scorecard_revisions( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_update_phrase_matcher_rest_flattened_error(transport: str = "rest"): +def test_list_qa_scorecard_revisions_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_phrase_matcher( - contact_center_insights.UpdatePhraseMatcherRequest(), - phrase_matcher=resources.PhraseMatcher(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.list_qa_scorecard_revisions( + contact_center_insights.ListQaScorecardRevisionsRequest(), + parent="parent_value", ) -def test_calculate_stats_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.calculate_stats in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListQaScorecardRevisionsResponse() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardRevisionsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_qa_scorecard_revisions( + parent="parent_value", ) - client._transport._wrapped_methods[client._transport.calculate_stats] = mock_rpc - request = {} - client.calculate_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - client.calculate_stats(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_qa_scorecard_revisions( + contact_center_insights.ListQaScorecardRevisionsRequest(), + parent="parent_value", + ) -def test_calculate_stats_rest_required_fields( - request_type=contact_center_insights.CalculateStatsRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - request_init = {} - request_init["location"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +def test_list_qa_scorecard_revisions_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).calculate_stats._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + ), + RuntimeError, + ) - # verify required fields with default values are now present + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_qa_scorecard_revisions( + request={}, retry=retry, timeout=timeout + ) - jsonified_request["location"] = "location_value" + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).calculate_stats._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter",)) - jsonified_request.update(unset_fields) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.QaScorecardRevision) for i in results) - # verify required fields with non-default values are left alone - assert "location" in jsonified_request - assert jsonified_request["location"] == "location_value" +def test_list_qa_scorecard_revisions_pages(transport_name: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport_name, ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateStatsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + ), + RuntimeError, + ) + pages = list(client.list_qa_scorecard_revisions(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Convert return value to protobuf type - return_value = contact_center_insights.CalculateStatsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response = client.calculate_stats(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_qa_scorecard_revisions( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + assert len(responses) == 6 + assert all(isinstance(i, resources.QaScorecardRevision) for i in responses) -def test_calculate_stats_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.calculate_stats._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter",)) & set(("location",))) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_qa_scorecard_revisions(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_calculate_stats_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateFeedbackLabelRequest, + dict, + ], +) +def test_create_feedback_label(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateStatsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"location": "projects/sample1/locations/sample2"} + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( - location="location_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + label="label_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.create_feedback_label(request) - client.calculate_stats(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateFeedbackLabelRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{location=projects/*/locations/*}/conversations:calculateStats" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FeedbackLabel) + assert response.name == "name_value" + assert response.labeled_resource == "labeled_resource_value" -def test_calculate_stats_rest_flattened_error(transport: str = "rest"): +def test_create_feedback_label_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.calculate_stats( - contact_center_insights.CalculateStatsRequest(), - location="location_value", + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.CreateFeedbackLabelRequest( + parent="parent_value", + feedback_label_id="feedback_label_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_feedback_label(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateFeedbackLabelRequest( + parent="parent_value", + feedback_label_id="feedback_label_id_value", ) -def test_get_settings_rest_use_cached_wrapped_rpc(): +def test_create_feedback_label_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -23022,360 +25312,368 @@ def test_get_settings_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_settings in client._transport._wrapped_methods + assert ( + client._transport.create_feedback_label + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_settings] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.create_feedback_label + ] = mock_rpc request = {} - client.get_settings(request) + client.create_feedback_label(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_settings(request) + client.create_feedback_label(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_settings_rest_required_fields( - request_type=contact_center_insights.GetSettingsRequest, +@pytest.mark.asyncio +async def test_create_feedback_label_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.create_feedback_label + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_feedback_label + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.create_feedback_label(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.create_feedback_label(request) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_create_feedback_label_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.CreateFeedbackLabelRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.Settings() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + ) + ) + response = await client.create_feedback_label(request) - # Convert return value to protobuf type - return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.CreateFeedbackLabelRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FeedbackLabel) + assert response.name == "name_value" + assert response.labeled_resource == "labeled_resource_value" - response = client.get_settings(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_create_feedback_label_async_from_dict(): + await test_create_feedback_label_async(request_type=dict) -def test_get_settings_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_create_feedback_label_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.get_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateFeedbackLabelRequest() + request.parent = "parent_value" -def test_get_settings_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + call.return_value = resources.FeedbackLabel() + client.create_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_feedback_label_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Settings() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateFeedbackLabelRequest() - # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/locations/sample2/settings"} + request.parent = "parent_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel() ) - mock_args.update(sample_request) + await client.create_feedback_label(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.get_settings(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_feedback_label_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_feedback_label( + parent="parent_value", + feedback_label=resources.FeedbackLabel(label="label_value"), + feedback_label_id="feedback_label_id_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/settings}" % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].feedback_label + mock_val = resources.FeedbackLabel(label="label_value") + assert arg == mock_val + arg = args[0].feedback_label_id + mock_val = "feedback_label_id_value" + assert arg == mock_val -def test_get_settings_rest_flattened_error(transport: str = "rest"): +def test_create_feedback_label_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_settings( - contact_center_insights.GetSettingsRequest(), - name="name_value", + client.create_feedback_label( + contact_center_insights.CreateFeedbackLabelRequest(), + parent="parent_value", + feedback_label=resources.FeedbackLabel(label="label_value"), + feedback_label_id="feedback_label_id_value", ) -def test_update_settings_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.update_settings] = mock_rpc - - request = {} - client.update_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_settings_rest_required_fields( - request_type=contact_center_insights.UpdateSettingsRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_settings._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", +@pytest.mark.asyncio +async def test_create_feedback_label_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Settings() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel() - response = client.update_settings(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_feedback_label( + parent="parent_value", + feedback_label=resources.FeedbackLabel(label="label_value"), + feedback_label_id="feedback_label_id_value", + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].feedback_label + mock_val = resources.FeedbackLabel(label="label_value") + assert arg == mock_val + arg = args[0].feedback_label_id + mock_val = "feedback_label_id_value" + assert arg == mock_val -def test_update_settings_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_create_feedback_label_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.update_settings._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("updateMask",)) - & set( - ( - "settings", - "updateMask", - ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_feedback_label( + contact_center_insights.CreateFeedbackLabelRequest(), + parent="parent_value", + feedback_label=resources.FeedbackLabel(label="label_value"), + feedback_label_id="feedback_label_id_value", ) - ) -def test_update_settings_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListFeedbackLabelsRequest, + dict, + ], +) +def test_list_feedback_labels(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Settings() - - # get arguments that satisfy an http rule for this method - sample_request = { - "settings": {"name": "projects/sample1/locations/sample2/settings"} - } + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( - settings=resources.Settings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListFeedbackLabelsResponse( + next_page_token="next_page_token_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.list_feedback_labels(request) - client.update_settings(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListFeedbackLabelsRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{settings.name=projects/*/locations/*/settings}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeedbackLabelsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_settings_rest_flattened_error(transport: str = "rest"): +def test_list_feedback_labels_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_settings( - contact_center_insights.UpdateSettingsRequest(), - settings=resources.Settings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.ListFeedbackLabelsRequest( + parent="parent_value", + filter="filter_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_feedback_labels(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListFeedbackLabelsRequest( + parent="parent_value", + filter="filter_value", + page_token="page_token_value", ) -def test_get_encryption_spec_rest_use_cached_wrapped_rpc(): +def test_list_feedback_labels_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -23384,7 +25682,7 @@ def test_get_encryption_spec_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.get_encryption_spec in client._transport._wrapped_methods + client._transport.list_feedback_labels in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -23393,349 +25691,536 @@ def test_get_encryption_spec_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_encryption_spec + client._transport.list_feedback_labels ] = mock_rpc - request = {} - client.get_encryption_spec(request) + client.list_feedback_labels(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_encryption_spec(request) + client.list_feedback_labels(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_encryption_spec_rest_required_fields( - request_type=contact_center_insights.GetEncryptionSpecRequest, +@pytest.mark.asyncio +async def test_list_feedback_labels_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.list_feedback_labels + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_encryption_spec._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_feedback_labels + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.list_feedback_labels(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_encryption_spec._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.list_feedback_labels(request) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_list_feedback_labels_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.ListFeedbackLabelsRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = resources.EncryptionSpec() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListFeedbackLabelsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_feedback_labels(request) - # Convert return value to protobuf type - return_value = resources.EncryptionSpec.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListFeedbackLabelsRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFeedbackLabelsAsyncPager) + assert response.next_page_token == "next_page_token_value" - response = client.get_encryption_spec(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_list_feedback_labels_async_from_dict(): + await test_list_feedback_labels_async(request_type=dict) -def test_get_encryption_spec_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_list_feedback_labels_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.get_encryption_spec._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListFeedbackLabelsRequest() + request.parent = "parent_value" -def test_get_encryption_spec_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + call.return_value = contact_center_insights.ListFeedbackLabelsResponse() + client.list_feedback_labels(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_feedback_labels_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.EncryptionSpec() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListFeedbackLabelsRequest() - # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/locations/sample2/encryptionSpec"} + request.parent = "parent_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListFeedbackLabelsResponse() ) - mock_args.update(sample_request) + await client.list_feedback_labels(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.EncryptionSpec.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.get_encryption_spec(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_feedback_labels_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListFeedbackLabelsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_feedback_labels( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/encryptionSpec}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_get_encryption_spec_rest_flattened_error(transport: str = "rest"): +def test_list_feedback_labels_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_encryption_spec( - contact_center_insights.GetEncryptionSpecRequest(), - name="name_value", + client.list_feedback_labels( + contact_center_insights.ListFeedbackLabelsRequest(), + parent="parent_value", ) -def test_initialize_encryption_spec_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +@pytest.mark.asyncio +async def test_list_feedback_labels_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListFeedbackLabelsResponse() - # Ensure method has been cached - assert ( - client._transport.initialize_encryption_spec - in client._transport._wrapped_methods + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListFeedbackLabelsResponse() ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_feedback_labels( + parent="parent_value", ) - client._transport._wrapped_methods[ - client._transport.initialize_encryption_spec - ] = mock_rpc - - request = {} - client.initialize_encryption_spec(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - client.initialize_encryption_spec(request) +@pytest.mark.asyncio +async def test_list_feedback_labels_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_feedback_labels( + contact_center_insights.ListFeedbackLabelsRequest(), + parent="parent_value", + ) -def test_initialize_encryption_spec_rest_required_fields( - request_type=contact_center_insights.InitializeEncryptionSpecRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport +def test_list_feedback_labels_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).initialize_encryption_spec._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_feedback_labels(request={}, retry=retry, timeout=timeout) - # verify required fields with default values are now present + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).initialize_encryption_spec._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.FeedbackLabel) for i in results) - # verify required fields with non-default values are left alone +def test_list_feedback_labels_pages(transport_name: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport_name, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) + pages = list(client.list_feedback_labels(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_list_feedback_labels_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - response = client.initialize_encryption_spec(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_feedback_labels( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + assert len(responses) == 6 + assert all(isinstance(i, resources.FeedbackLabel) for i in responses) -def test_initialize_encryption_spec_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_feedback_labels_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.initialize_encryption_spec._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("encryptionSpec",))) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_feedback_labels(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_initialize_encryption_spec_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetFeedbackLabelRequest, + dict, + ], +) +def test_get_feedback_label(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = { - "encryption_spec": { - "name": "projects/sample1/locations/sample2/encryptionSpec" - } - } + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( - encryption_spec=resources.EncryptionSpec(name="name_value"), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + label="label_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.get_feedback_label(request) - client.initialize_encryption_spec(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetFeedbackLabelRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{encryption_spec.name=projects/*/locations/*/encryptionSpec}:initialize" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FeedbackLabel) + assert response.name == "name_value" + assert response.labeled_resource == "labeled_resource_value" -def test_initialize_encryption_spec_rest_flattened_error(transport: str = "rest"): +def test_get_feedback_label_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.initialize_encryption_spec( - contact_center_insights.InitializeEncryptionSpecRequest(), - encryption_spec=resources.EncryptionSpec(name="name_value"), + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.GetFeedbackLabelRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_feedback_label(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetFeedbackLabelRequest( + name="name_value", ) -def test_create_view_rest_use_cached_wrapped_rpc(): +def test_get_feedback_label_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -23743,360 +26228,342 @@ def test_create_view_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.create_view in client._transport._wrapped_methods + assert ( + client._transport.get_feedback_label in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.create_view] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.get_feedback_label + ] = mock_rpc request = {} - client.create_view(request) + client.get_feedback_label(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.create_view(request) + client.get_feedback_label(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_create_view_rest_required_fields( - request_type=contact_center_insights.CreateViewRequest, +@pytest.mark.asyncio +async def test_get_feedback_label_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_feedback_label + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_feedback_label + ] = mock_rpc + + request = {} + await client.get_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_feedback_label(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_feedback_label_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.GetFeedbackLabelRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + ) + ) + response = await client.get_feedback_label(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.GetFeedbackLabelRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FeedbackLabel) + assert response.name == "name_value" + assert response.labeled_resource == "labeled_resource_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_get_feedback_label_async_from_dict(): + await test_get_feedback_label_async(request_type=dict) + +def test_get_feedback_label_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.View() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetFeedbackLabelRequest() - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + call.return_value = resources.FeedbackLabel() + client.get_feedback_label(request) - response = client.create_view(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_create_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_feedback_label_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.create_view._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "view", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetFeedbackLabelRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel() ) - ) + await client.get_feedback_label(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_create_view_rest_flattened(): + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_feedback_label_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.View() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - view=resources.View(name="name_value"), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_feedback_label( + name="name_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.create_view(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_create_view_rest_flattened_error(transport: str = "rest"): +def test_get_feedback_label_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_view( - contact_center_insights.CreateViewRequest(), - parent="parent_value", - view=resources.View(name="name_value"), + client.get_feedback_label( + contact_center_insights.GetFeedbackLabelRequest(), + name="name_value", ) -def test_get_view_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_get_feedback_label_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.get_view in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_feedback_label( + name="name_value", ) - client._transport._wrapped_methods[client._transport.get_view] = mock_rpc - request = {} - client.get_view(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_view(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_view_rest_required_fields( - request_type=contact_center_insights.GetViewRequest, -): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = "name_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.View() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.get_view(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_get_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_feedback_label_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_view._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_feedback_label( + contact_center_insights.GetFeedbackLabelRequest(), + name="name_value", + ) -def test_get_view_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateFeedbackLabelRequest, + dict, + ], +) +def test_update_feedback_label(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.View() - - # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/locations/sample2/views/sample3"} + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel( name="name_value", + labeled_resource="labeled_resource_value", + label="label_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + response = client.update_feedback_label(request) - client.get_view(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateFeedbackLabelRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FeedbackLabel) + assert response.name == "name_value" + assert response.labeled_resource == "labeled_resource_value" -def test_get_view_rest_flattened_error(transport: str = "rest"): +def test_update_feedback_label_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_view( - contact_center_insights.GetViewRequest(), - name="name_value", + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.UpdateFeedbackLabelRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) + client.update_feedback_label(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateFeedbackLabelRequest() -def test_list_views_rest_use_cached_wrapped_rpc(): +def test_update_feedback_label_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -24104,429 +26571,689 @@ def test_list_views_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_views in client._transport._wrapped_methods + assert ( + client._transport.update_feedback_label + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_views] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.update_feedback_label + ] = mock_rpc request = {} - client.list_views(request) + client.update_feedback_label(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_views(request) + client.update_feedback_label(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_views_rest_required_fields( - request_type=contact_center_insights.ListViewsRequest, +@pytest.mark.asyncio +async def test_update_feedback_label_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.update_feedback_label + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_views._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_feedback_label + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.update_feedback_label(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_views._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) + await client.update_feedback_label(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_feedback_label_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UpdateFeedbackLabelRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + ) + ) + response = await client.update_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.UpdateFeedbackLabelRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FeedbackLabel) + assert response.name == "name_value" + assert response.labeled_resource == "labeled_resource_value" + + +@pytest.mark.asyncio +async def test_update_feedback_label_async_from_dict(): + await test_update_feedback_label_async(request_type=dict) + +def test_update_feedback_label_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListViewsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateFeedbackLabelRequest() - # Convert return value to protobuf type - return_value = contact_center_insights.ListViewsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.feedback_label.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + call.return_value = resources.FeedbackLabel() + client.update_feedback_label(request) - response = client.list_views(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "feedback_label.name=name_value", + ) in kw["metadata"] -def test_list_views_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_update_feedback_label_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_views._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateFeedbackLabelRequest() + + request.feedback_label.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel() ) - & set(("parent",)) - ) + await client.update_feedback_label(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_list_views_rest_flattened(): + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "feedback_label.name=name_value", + ) in kw["metadata"] + + +def test_update_feedback_label_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListViewsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_feedback_label( + feedback_label=resources.FeedbackLabel(label="label_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = contact_center_insights.ListViewsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_views(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].feedback_label + mock_val = resources.FeedbackLabel(label="label_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val -def test_list_views_rest_flattened_error(transport: str = "rest"): +def test_update_feedback_label_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_views( - contact_center_insights.ListViewsRequest(), - parent="parent_value", + client.update_feedback_label( + contact_center_insights.UpdateFeedbackLabelRequest(), + feedback_label=resources.FeedbackLabel(label="label_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_list_views_rest_pager(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_update_feedback_label_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token="abc", - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token="def", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token="ghi", - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - ) - # Two responses for two calls - response = response + response + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FeedbackLabel() - # Wrap the values into proper Response objs - response = tuple( - contact_center_insights.ListViewsResponse.to_json(x) for x in response + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_feedback_label( + feedback_label=resources.FeedbackLabel(label="label_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].feedback_label + mock_val = resources.FeedbackLabel(label="label_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val - pager = client.list_views(request=sample_request) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.View) for i in results) +@pytest.mark.asyncio +async def test_update_feedback_label_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) - pages = list(client.list_views(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_feedback_label( + contact_center_insights.UpdateFeedbackLabelRequest(), + feedback_label=resources.FeedbackLabel(label="label_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) -def test_update_view_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteFeedbackLabelRequest, + dict, + ], +) +def test_delete_feedback_label(request_type, transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # Ensure method has been cached - assert client._transport.update_view in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteFeedbackLabelRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_feedback_label_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.DeleteFeedbackLabelRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_feedback_label(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteFeedbackLabelRequest( + name="name_value", + ) + + +def test_delete_feedback_label_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_feedback_label + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.update_view] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.delete_feedback_label + ] = mock_rpc request = {} - client.update_view(request) + client.delete_feedback_label(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_view(request) + client.delete_feedback_label(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_view_rest_required_fields( - request_type=contact_center_insights.UpdateViewRequest, +@pytest.mark.asyncio +async def test_delete_feedback_label_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.delete_feedback_label + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_feedback_label + ] = mock_rpc + + request = {} + await client.delete_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.delete_feedback_label(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_feedback_label_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.DeleteFeedbackLabelRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_feedback_label(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.DeleteFeedbackLabelRequest() + assert args[0] == request - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_view._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) - jsonified_request.update(unset_fields) + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_feedback_label_async_from_dict(): + await test_delete_feedback_label_async(request_type=dict) - # verify required fields with non-default values are left alone +def test_delete_feedback_label_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.View() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteFeedbackLabelRequest() - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + call.return_value = None + client.delete_feedback_label(request) - response = client.update_view(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_update_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_delete_feedback_label_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.update_view._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("view",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteFeedbackLabelRequest() + request.name = "name_value" -def test_update_view_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_feedback_label_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.View() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_feedback_label( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "view": {"name": "projects/sample1/locations/sample2/views/sample3"} - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( - view=resources.View(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + +def test_delete_feedback_label_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_feedback_label( + contact_center_insights.DeleteFeedbackLabelRequest(), + name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.update_view(**mock_args) +@pytest.mark.asyncio +async def test_delete_feedback_label_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_feedback_label( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{view.name=projects/*/locations/*/views/*}" % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_feedback_label_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_feedback_label( + contact_center_insights.DeleteFeedbackLabelRequest(), + name="name_value", ) -def test_update_view_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListAllFeedbackLabelsRequest, + dict, + ], +) +def test_list_all_feedback_labels(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_view( - contact_center_insights.UpdateViewRequest(), - view=resources.View(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAllFeedbackLabelsResponse( + next_page_token="next_page_token_value", ) + response = client.list_all_feedback_labels(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListAllFeedbackLabelsRequest() + assert args[0] == request -def test_delete_view_rest_use_cached_wrapped_rpc(): + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAllFeedbackLabelsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_all_feedback_labels_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.ListAllFeedbackLabelsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_all_feedback_labels(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListAllFeedbackLabelsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + ) + + +def test_list_all_feedback_labels_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -24534,2620 +27261,24842 @@ def test_delete_view_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_view in client._transport._wrapped_methods + assert ( + client._transport.list_all_feedback_labels + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_view] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.list_all_feedback_labels + ] = mock_rpc request = {} - client.delete_view(request) + client.list_all_feedback_labels(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.delete_view(request) + client.list_all_feedback_labels(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_view_rest_required_fields( - request_type=contact_center_insights.DeleteViewRequest, +@pytest.mark.asyncio +async def test_list_all_feedback_labels_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - # verify fields with default values are dropped + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Ensure method has been cached + assert ( + client._client._transport.list_all_feedback_labels + in client._client._transport._wrapped_methods + ) - # verify required fields with default values are now present + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_all_feedback_labels + ] = mock_rpc - jsonified_request["name"] = "name_value" + request = {} + await client.list_all_feedback_labels(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + await client.list_all_feedback_labels(request) - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 - json_return_value = "" +@pytest.mark.asyncio +async def test_list_all_feedback_labels_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.ListAllFeedbackLabelsRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response = client.delete_view(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAllFeedbackLabelsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_all_feedback_labels(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = contact_center_insights.ListAllFeedbackLabelsRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAllFeedbackLabelsAsyncPager) + assert response.next_page_token == "next_page_token_value" -def test_delete_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - unset_fields = transport.delete_view._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) +@pytest.mark.asyncio +async def test_list_all_feedback_labels_async_from_dict(): + await test_list_all_feedback_labels_async(request_type=dict) -def test_delete_view_rest_flattened(): +def test_list_all_feedback_labels_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListAllFeedbackLabelsRequest() - # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/locations/sample2/views/sample3"} + request.parent = "parent_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + call.return_value = contact_center_insights.ListAllFeedbackLabelsResponse() + client.list_all_feedback_labels(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.delete_view(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, - args[1], - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_delete_view_rest_flattened_error(transport: str = "rest"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_list_all_feedback_labels_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_view( - contact_center_insights.DeleteViewRequest(), - name="name_value", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListAllFeedbackLabelsRequest() + request.parent = "parent_value" -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAllFeedbackLabelsResponse() ) + await client.list_all_feedback_labels(request) - # It is an error to provide a credentials file and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - # It is an error to provide an api_key and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options=options, - transport=transport, - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) - # It is an error to provide scopes and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( +def test_list_all_feedback_labels_flattened(): + client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAllFeedbackLabelsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_all_feedback_labels( + parent="parent_value", ) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( + +def test_list_all_feedback_labels_flattened_error(): + client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) - client = ContactCenterInsightsClient(transport=transport) - assert client.transport is transport + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_all_feedback_labels( + contact_center_insights.ListAllFeedbackLabelsRequest(), + parent="parent_value", + ) -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), +@pytest.mark.asyncio +async def test_list_all_feedback_labels_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ContactCenterInsightsGrpcTransport, - transports.ContactCenterInsightsGrpcAsyncIOTransport, - transports.ContactCenterInsightsRestTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAllFeedbackLabelsResponse() + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAllFeedbackLabelsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_all_feedback_labels( + parent="parent_value", + ) -def test_transport_kind_grpc(): - transport = ContactCenterInsightsClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_initialize_client_w_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc" +@pytest.mark.asyncio +async def test_list_all_feedback_labels_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - assert client is not None + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_all_feedback_labels( + contact_center_insights.ListAllFeedbackLabelsRequest(), + parent="parent_value", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_conversation_empty_call_grpc(): +def test_list_all_feedback_labels_pager(transport_name: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport_name, ) - # Mock the actual call, and fake the request. + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_conversation), "__call__" + type(client.transport.list_all_feedback_labels), "__call__" ) as call: - call.return_value = resources.Conversation() - client.create_conversation(request=None) + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateConversationRequest() + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_all_feedback_labels( + request={}, retry=retry, timeout=timeout + ) - assert args[0] == request_msg + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.FeedbackLabel) for i in results) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_upload_conversation_empty_call_grpc(): + +def test_list_all_feedback_labels_pages(transport_name: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport_name, ) - # Mock the actual call, and fake the request. + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.upload_conversation), "__call__" + type(client.transport.list_all_feedback_labels), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.upload_conversation(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UploadConversationRequest() - - assert args[0] == request_msg + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) + pages = list(client.list_all_feedback_labels(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_conversation_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_list_all_feedback_labels_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the actual call, and fake the request. + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_conversation), "__call__" + type(client.transport.list_all_feedback_labels), + "__call__", + new_callable=mock.AsyncMock, ) as call: - call.return_value = resources.Conversation() - client.update_conversation(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateConversationRequest() + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_all_feedback_labels( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - assert args[0] == request_msg + assert len(responses) == 6 + assert all(isinstance(i, resources.FeedbackLabel) for i in responses) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_conversation_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_list_all_feedback_labels_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_conversation), "__call__") as call: - call.return_value = resources.Conversation() - client.get_conversation(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetConversationRequest() - - assert args[0] == request_msg + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_all_feedback_labels(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_conversations_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.BulkUploadFeedbackLabelsRequest, + dict, + ], +) +def test_bulk_upload_feedback_labels(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_conversations), "__call__" + type(client.transport.bulk_upload_feedback_labels), "__call__" ) as call: - call.return_value = contact_center_insights.ListConversationsResponse() - client.list_conversations(request=None) + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.bulk_upload_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListConversationsRequest() + request = contact_center_insights.BulkUploadFeedbackLabelsRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_conversation_empty_call_grpc(): +def test_bulk_upload_feedback_labels_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) - # Mock the actual call, and fake the request. + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.BulkUploadFeedbackLabelsRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_conversation), "__call__" + type(client.transport.bulk_upload_feedback_labels), "__call__" ) as call: - call.return_value = None - client.delete_conversation(request=None) - - # Establish that the underlying stub method was called. + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.bulk_upload_feedback_labels(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteConversationRequest() - - assert args[0] == request_msg + assert args[0] == contact_center_insights.BulkUploadFeedbackLabelsRequest( + parent="parent_value", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_analysis_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) +def test_bulk_upload_feedback_labels_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_analysis), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_analysis(request=None) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateAnalysisRequest() + # Ensure method has been cached + assert ( + client._transport.bulk_upload_feedback_labels + in client._transport._wrapped_methods + ) - assert args[0] == request_msg + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.bulk_upload_feedback_labels + ] = mock_rpc + request = {} + client.bulk_upload_feedback_labels(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_analysis_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_analysis), "__call__") as call: - call.return_value = resources.Analysis() - client.get_analysis(request=None) + client.bulk_upload_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetAnalysisRequest() + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - assert args[0] == request_msg +@pytest.mark.asyncio +async def test_bulk_upload_feedback_labels_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_analyses_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_analyses), "__call__") as call: - call.return_value = contact_center_insights.ListAnalysesResponse() - client.list_analyses(request=None) + # Ensure method has been cached + assert ( + client._client._transport.bulk_upload_feedback_labels + in client._client._transport._wrapped_methods + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListAnalysesRequest() + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.bulk_upload_feedback_labels + ] = mock_rpc - assert args[0] == request_msg + request = {} + await client.bulk_upload_feedback_labels(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_analysis_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_analysis), "__call__") as call: - call.return_value = None - client.delete_analysis(request=None) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteAnalysisRequest() + await client.bulk_upload_feedback_labels(request) - assert args[0] == request_msg + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_bulk_analyze_conversations_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_bulk_upload_feedback_labels_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.BulkUploadFeedbackLabelsRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # Mock the actual call, and fake the request. + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.bulk_analyze_conversations), "__call__" + type(client.transport.bulk_upload_feedback_labels), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.bulk_analyze_conversations(request=None) + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.bulk_upload_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.BulkAnalyzeConversationsRequest() + request = contact_center_insights.BulkUploadFeedbackLabelsRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_bulk_delete_conversations_empty_call_grpc(): +@pytest.mark.asyncio +async def test_bulk_upload_feedback_labels_async_from_dict(): + await test_bulk_upload_feedback_labels_async(request_type=dict) + + +def test_bulk_upload_feedback_labels_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", ) - # Mock the actual call, and fake the request. + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.BulkUploadFeedbackLabelsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.bulk_delete_conversations), "__call__" + type(client.transport.bulk_upload_feedback_labels), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.bulk_delete_conversations(request=None) + client.bulk_upload_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.BulkDeleteConversationsRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_ingest_conversations_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_bulk_upload_feedback_labels_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the actual call, and fake the request. + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.BulkUploadFeedbackLabelsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.ingest_conversations), "__call__" + type(client.transport.bulk_upload_feedback_labels), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.ingest_conversations(request=None) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.bulk_upload_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.IngestConversationsRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_export_insights_data_empty_call_grpc(): +def test_bulk_upload_feedback_labels_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", ) - # Mock the actual call, and fake the request. + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.export_insights_data), "__call__" + type(client.transport.bulk_upload_feedback_labels), "__call__" ) as call: + # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - client.export_insights_data(request=None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.bulk_upload_feedback_labels( + parent="parent_value", + ) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ExportInsightsDataRequest() - - assert args[0] == request_msg + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_issue_model_empty_call_grpc(): +def test_bulk_upload_feedback_labels_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", ) - # Mock the actual call, and fake the request. + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_upload_feedback_labels( + contact_center_insights.BulkUploadFeedbackLabelsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_bulk_upload_feedback_labels_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_issue_model), "__call__" + type(client.transport.bulk_upload_feedback_labels), "__call__" ) as call: + # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - client.create_issue_model(request=None) - # Establish that the underlying stub method was called. - call.assert_called() + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.bulk_upload_feedback_labels( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateIssueModelRequest() + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - assert args[0] == request_msg +@pytest.mark.asyncio +async def test_bulk_upload_feedback_labels_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_issue_model_empty_call_grpc(): + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.bulk_upload_feedback_labels( + contact_center_insights.BulkUploadFeedbackLabelsRequest(), + parent="parent_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.BulkDownloadFeedbackLabelsRequest, + dict, + ], +) +def test_bulk_download_feedback_labels(request_type, transport: str = "grpc"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_issue_model), "__call__" + type(client.transport.bulk_download_feedback_labels), "__call__" ) as call: - call.return_value = resources.IssueModel() - client.update_issue_model(request=None) + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.bulk_download_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateIssueModelRequest() + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_issue_model_empty_call_grpc(): +def test_bulk_download_feedback_labels_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: - call.return_value = resources.IssueModel() - client.get_issue_model(request=None) + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest( + parent="parent_value", + filter="filter_value", + conversation_filter="conversation_filter_value", + ) - # Establish that the underlying stub method was called. + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_download_feedback_labels), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.bulk_download_feedback_labels(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetIssueModelRequest() + assert args[0] == contact_center_insights.BulkDownloadFeedbackLabelsRequest( + parent="parent_value", + filter="filter_value", + conversation_filter="conversation_filter_value", + ) - assert args[0] == request_msg +def test_bulk_download_feedback_labels_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_issue_models_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert ( + client._transport.bulk_download_feedback_labels + in client._transport._wrapped_methods + ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), "__call__" - ) as call: - call.return_value = contact_center_insights.ListIssueModelsResponse() - client.list_issue_models(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.bulk_download_feedback_labels + ] = mock_rpc + request = {} + client.bulk_download_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListIssueModelsRequest() + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - assert args[0] == request_msg + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + client.bulk_download_feedback_labels(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_issue_model_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_issue_model(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteIssueModelRequest() +@pytest.mark.asyncio +async def test_bulk_download_feedback_labels_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - assert args[0] == request_msg + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.bulk_download_feedback_labels + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.bulk_download_feedback_labels + ] = mock_rpc + request = {} + await client.bulk_download_feedback_labels(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_deploy_issue_model_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.bulk_download_feedback_labels(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_bulk_download_feedback_labels_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.BulkDownloadFeedbackLabelsRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # Mock the actual call, and fake the request. + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.deploy_issue_model), "__call__" + type(client.transport.bulk_download_feedback_labels), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.deploy_issue_model(request=None) + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.bulk_download_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeployIssueModelRequest() + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_undeploy_issue_model_empty_call_grpc(): +@pytest.mark.asyncio +async def test_bulk_download_feedback_labels_async_from_dict(): + await test_bulk_download_feedback_labels_async(request_type=dict) + + +def test_bulk_download_feedback_labels_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", ) - # Mock the actual call, and fake the request. + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.undeploy_issue_model), "__call__" + type(client.transport.bulk_download_feedback_labels), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.undeploy_issue_model(request=None) + client.bulk_download_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UndeployIssueModelRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_export_issue_model_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_bulk_download_feedback_labels_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the actual call, and fake the request. + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.export_issue_model), "__call__" + type(client.transport.bulk_download_feedback_labels), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.export_issue_model(request=None) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.bulk_download_feedback_labels(request) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ExportIssueModelRequest() + assert args[0] == request - assert args[0] == request_msg + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_import_issue_model_empty_call_grpc(): +def test_bulk_download_feedback_labels_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", ) - # Mock the actual call, and fake the request. + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_issue_model), "__call__" + type(client.transport.bulk_download_feedback_labels), "__call__" ) as call: + # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - client.import_issue_model(request=None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.bulk_download_feedback_labels( + parent="parent_value", + ) - # Establish that the underlying stub method was called. - call.assert_called() + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ImportIssueModelRequest() - - assert args[0] == request_msg + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_issue_empty_call_grpc(): +def test_bulk_download_feedback_labels_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_issue), "__call__") as call: - call.return_value = resources.Issue() - client.get_issue(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetIssueRequest() - - assert args[0] == request_msg + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_download_feedback_labels( + contact_center_insights.BulkDownloadFeedbackLabelsRequest(), + parent="parent_value", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_issues_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_bulk_download_feedback_labels_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_issues), "__call__") as call: - call.return_value = contact_center_insights.ListIssuesResponse() - client.list_issues(request=None) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_download_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListIssuesRequest() + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.bulk_download_feedback_labels( + parent="parent_value", + ) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_issue_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_bulk_download_feedback_labels_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_issue), "__call__") as call: - call.return_value = resources.Issue() - client.update_issue(request=None) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.bulk_download_feedback_labels( + contact_center_insights.BulkDownloadFeedbackLabelsRequest(), + parent="parent_value", + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateIssueRequest() - assert args[0] == request_msg +def test_create_conversation_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_issue_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert ( + client._transport.create_conversation in client._transport._wrapped_methods + ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: - call.return_value = None - client.delete_issue(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_conversation + ] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteIssueRequest() + request = {} + client.create_conversation(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.create_conversation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_calculate_issue_model_stats_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), "__call__" - ) as call: - call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() - client.calculate_issue_model_stats(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CalculateIssueModelStatsRequest() +def test_create_conversation_rest_required_fields( + request_type=contact_center_insights.CreateConversationRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport - assert args[0] == request_msg + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_phrase_matcher_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), "__call__" - ) as call: - call.return_value = resources.PhraseMatcher() - client.create_phrase_matcher(request=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreatePhraseMatcherRequest() + jsonified_request["parent"] = "parent_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("conversation_id",)) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_phrase_matcher_empty_call_grpc(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), "__call__" - ) as call: - call.return_value = resources.PhraseMatcher() - client.get_phrase_matcher(request=None) + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetPhraseMatcherRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_phrase_matchers_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + response = client.create_conversation(request) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), "__call__" - ) as call: - call.return_value = contact_center_insights.ListPhraseMatchersResponse() - client.list_phrase_matchers(request=None) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListPhraseMatchersRequest() - assert args[0] == request_msg +def test_create_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + unset_fields = transport.create_conversation._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("conversationId",)) + & set( + ( + "parent", + "conversation", + ) + ) + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_phrase_matcher_empty_call_grpc(): + +def test_create_conversation_rest_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), "__call__" - ) as call: - call.return_value = None - client.delete_phrase_matcher(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeletePhraseMatcherRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_phrase_matcher_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + conversation=resources.Conversation( + call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) + ), + conversation_id="conversation_id_value", + ) + mock_args.update(sample_request) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), "__call__" - ) as call: - call.return_value = resources.PhraseMatcher() - client.update_phrase_matcher(request=None) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdatePhraseMatcherRequest() + client.create_conversation(**mock_args) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/conversations" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_calculate_stats_empty_call_grpc(): +def test_create_conversation_rest_flattened_error(transport: str = "rest"): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.calculate_stats), "__call__") as call: - call.return_value = contact_center_insights.CalculateStatsResponse() - client.calculate_stats(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CalculateStatsRequest() + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_conversation( + contact_center_insights.CreateConversationRequest(), + parent="parent_value", + conversation=resources.Conversation( + call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) + ), + conversation_id="conversation_id_value", + ) - assert args[0] == request_msg +def test_upload_conversation_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_settings_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_settings), "__call__") as call: - call.return_value = resources.Settings() - client.get_settings(request=None) + # Ensure method has been cached + assert ( + client._transport.upload_conversation in client._transport._wrapped_methods + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetSettingsRequest() + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.upload_conversation + ] = mock_rpc - assert args[0] == request_msg + request = {} + client.upload_conversation(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_settings_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_settings), "__call__") as call: - call.return_value = resources.Settings() - client.update_settings(request=None) + client.upload_conversation(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateSettingsRequest() + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - assert args[0] == request_msg +def test_upload_conversation_rest_required_fields( + request_type=contact_center_insights.UploadConversationRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_encryption_spec_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" - ) as call: - call.return_value = resources.EncryptionSpec() - client.get_encryption_spec(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetEncryptionSpecRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).upload_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).upload_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_initialize_encryption_spec_empty_call_grpc(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.initialize_encryption_spec(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.InitializeEncryptionSpecRequest() - - assert args[0] == request_msg + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_view_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: - call.return_value = resources.View() - client.create_view(request=None) + response = client.upload_conversation(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateViewRequest() + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - assert args[0] == request_msg +def test_upload_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_view_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + unset_fields = transport.upload_conversation._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "conversation", + ) + ) ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: - call.return_value = resources.View() - client.get_view(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetViewRequest() +def test_update_conversation_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) - assert args[0] == request_msg + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + # Ensure method has been cached + assert ( + client._transport.update_conversation in client._transport._wrapped_methods + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_views_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_conversation + ] = mock_rpc - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: - call.return_value = contact_center_insights.ListViewsResponse() - client.list_views(request=None) + request = {} + client.update_conversation(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListViewsRequest() + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - assert args[0] == request_msg + client.update_conversation(request) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_view_empty_call_grpc(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + +def test_update_conversation_rest_required_fields( + request_type=contact_center_insights.UpdateConversationRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: - call.return_value = resources.View() - client.update_view(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateViewRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_view_empty_call_grpc(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: - call.return_value = None - client.delete_view(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteViewRequest() + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result - assert args[0] == request_msg + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) -def test_transport_kind_grpc_asyncio(): - transport = ContactCenterInsightsAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_conversation(request) -def test_initialize_client_w_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), transport="grpc_asyncio" - ) - assert client is not None + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_conversation_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Conversation( - name="name_value", - language_code="language_code_value", - agent_id="agent_id_value", - metadata_json="metadata_json_value", - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id="obfuscated_user_id_value", - ) - ) - await client.create_conversation(request=None) + unset_fields = transport.update_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("conversation",))) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateConversationRequest() - assert args[0] == request_msg +def test_update_conversation_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_upload_conversation_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = { + "conversation": { + "name": "projects/sample1/locations/sample2/conversations/sample3" + } + } - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.upload_conversation), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # get truthy value for each flattened field + mock_args = dict( + conversation=resources.Conversation( + call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - await client.upload_conversation(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UploadConversationRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.update_conversation(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{conversation.name=projects/*/locations/*/conversations/*}" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_conversation_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_conversation_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Conversation( - name="name_value", - language_code="language_code_value", - agent_id="agent_id_value", - metadata_json="metadata_json_value", - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id="obfuscated_user_id_value", - ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_conversation( + contact_center_insights.UpdateConversationRequest(), + conversation=resources.Conversation( + call_metadata=resources.Conversation.CallMetadata(customer_channel=1706) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - await client.update_conversation(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateConversationRequest() - assert args[0] == request_msg +def test_get_conversation_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_conversation_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert client._transport.get_conversation in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_conversation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Conversation( - name="name_value", - language_code="language_code_value", - agent_id="agent_id_value", - metadata_json="metadata_json_value", - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id="obfuscated_user_id_value", - ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) - await client.get_conversation(request=None) + client._transport._wrapped_methods[ + client._transport.get_conversation + ] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetConversationRequest() + request = {} + client.get_conversation(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.get_conversation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_conversations_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListConversationsResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_conversations(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListConversationsRequest() +def test_get_conversation_rest_required_fields( + request_type=contact_center_insights.GetConversationRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport - assert args[0] == request_msg + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_conversation_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_conversation(request=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteConversationRequest() + jsonified_request["name"] = "name_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("view",)) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_analysis_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_analysis), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_analysis(request=None) + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateAnalysisRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_analysis_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + response = client.get_conversation(request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_analysis), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Analysis( - name="name_value", - ) - ) - await client.get_analysis(request=None) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetAnalysisRequest() - assert args[0] == request_msg +def test_get_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + unset_fields = transport.get_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(("view",)) & set(("name",))) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_analyses_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_analyses), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListAnalysesResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_analyses(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListAnalysesRequest() +def test_get_conversation_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) - assert args[0] == request_msg + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/conversations/sample3" + } -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_analysis_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_analysis), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_analysis(request=None) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteAnalysisRequest() + client.get_conversation(**mock_args) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/conversations/*}" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_bulk_analyze_conversations_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_conversation_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_conversation( + contact_center_insights.GetConversationRequest(), + name="name_value", ) - await client.bulk_analyze_conversations(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.BulkAnalyzeConversationsRequest() - assert args[0] == request_msg +def test_list_conversations_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_bulk_delete_conversations_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.bulk_delete_conversations), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Ensure method has been cached + assert ( + client._transport.list_conversations in client._transport._wrapped_methods ) - await client.bulk_delete_conversations(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.BulkDeleteConversationsRequest() - assert args[0] == request_msg + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_conversations + ] = mock_rpc + request = {} + client.list_conversations(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_ingest_conversations_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.ingest_conversations(request=None) + client.list_conversations(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.IngestConversationsRequest() + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - assert args[0] == request_msg +def test_list_conversations_rest_required_fields( + request_type=contact_center_insights.ListConversationsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_export_insights_data_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.export_insights_data(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ExportInsightsDataRequest() + # verify fields with default values are dropped - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with default values are now present -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + jsonified_request["parent"] = "parent_value" - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_conversations._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + "view", ) - await client.create_issue_model(request=None) + ) + jsonified_request.update(unset_fields) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateIssueModelRequest() + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" - assert args[0] == request_msg + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListConversationsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + response_value = Response() + response_value.status_code = 200 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IssueModel( - name="name_value", - display_name="display_name_value", - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code="language_code_value", + # Convert return value to protobuf type + return_value = contact_center_insights.ListConversationsResponse.pb( + return_value ) - ) - await client.update_issue_model(request=None) + json_return_value = json_format.MessageToJson(return_value) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateIssueModelRequest() + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + response = client.list_conversations(request) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +def test_list_conversations_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IssueModel( - name="name_value", - display_name="display_name_value", - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code="language_code_value", + unset_fields = transport.list_conversations._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + "view", ) ) - await client.get_issue_model(request=None) + & set(("parent",)) + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetIssueModelRequest() - assert args[0] == request_msg +def test_list_conversations_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListConversationsResponse() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_issue_models_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListIssueModelsResponse() + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", ) - await client.list_issue_models(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListIssueModelsRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListConversationsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.list_conversations(**mock_args) + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/conversations" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +def test_list_conversations_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_conversations( + contact_center_insights.ListConversationsRequest(), + parent="parent_value", ) - await client.delete_issue_model(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteIssueModelRequest() - - assert args[0] == request_msg -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_deploy_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_conversations_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token="abc", + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token="def", + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), ) - await client.deploy_issue_model(request=None) + # Two responses for two calls + response = response + response - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeployIssueModelRequest() + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListConversationsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values - assert args[0] == request_msg + sample_request = {"parent": "projects/sample1/locations/sample2"} + pager = client.list_conversations(request=sample_request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_undeploy_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Conversation) for i in results) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.undeploy_issue_model(request=None) + pages = list(client.list_conversations(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UndeployIssueModelRequest() - assert args[0] == request_msg +def test_delete_conversation_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_export_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert ( + client._transport.delete_conversation in client._transport._wrapped_methods + ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_issue_model), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) - await client.export_issue_model(request=None) + client._transport._wrapped_methods[ + client._transport.delete_conversation + ] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ExportIssueModelRequest() + request = {} + client.delete_conversation(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.delete_conversation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_issue_model_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_issue_model), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.import_issue_model(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ImportIssueModelRequest() +def test_delete_conversation_rest_required_fields( + request_type=contact_center_insights.DeleteConversationRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport - assert args[0] == request_msg + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_issue_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_issue), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Issue( - name="name_value", - display_name="display_name_value", - sample_utterances=["sample_utterances_value"], - display_description="display_description_value", - ) - ) - await client.get_issue(request=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetIssueRequest() + jsonified_request["name"] = "name_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("force",)) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_issues_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_issues), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListIssuesResponse() - ) - await client.list_issues(request=None) + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListIssuesRequest() + response_value = Response() + response_value.status_code = 200 + json_return_value = "" - assert args[0] == request_msg + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_conversation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_issue_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_issue), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Issue( - name="name_value", - display_name="display_name_value", - sample_utterances=["sample_utterances_value"], - display_description="display_description_value", - ) - ) - await client.update_issue(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateIssueRequest() +def test_delete_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - assert args[0] == request_msg + unset_fields = transport.delete_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(("force",)) & set(("name",))) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_issue_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_delete_conversation_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_issue(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteIssueRequest() + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/conversations/sample3" + } - assert args[0] == request_msg + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_calculate_issue_model_stats_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + client.delete_conversation(**mock_args) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.CalculateIssueModelStatsResponse() + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/conversations/*}" + % client.transport._host, + args[1], ) - await client.calculate_issue_model_stats(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CalculateIssueModelStatsRequest() - - assert args[0] == request_msg -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_phrase_matcher_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_delete_conversation_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.PhraseMatcher( - name="name_value", - revision_id="revision_id_value", - version_tag="version_tag_value", - display_name="display_name_value", - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_conversation( + contact_center_insights.DeleteConversationRequest(), + name="name_value", ) - await client.create_phrase_matcher(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreatePhraseMatcherRequest() - assert args[0] == request_msg +def test_create_analysis_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_phrase_matcher_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert client._transport.create_analysis in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.PhraseMatcher( - name="name_value", - revision_id="revision_id_value", - version_tag="version_tag_value", - display_name="display_name_value", - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) - await client.get_phrase_matcher(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetPhraseMatcherRequest() + client._transport._wrapped_methods[client._transport.create_analysis] = mock_rpc - assert args[0] == request_msg + request = {} + client.create_analysis(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_phrase_matchers_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListPhraseMatchersResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_phrase_matchers(request=None) + client.create_analysis(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListPhraseMatchersRequest() + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - assert args[0] == request_msg +def test_create_analysis_rest_required_fields( + request_type=contact_center_insights.CreateAnalysisRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_phrase_matcher_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_phrase_matcher(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeletePhraseMatcherRequest() - - assert args[0] == request_msg - + # verify fields with default values are dropped -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_phrase_matcher_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.PhraseMatcher( - name="name_value", - revision_id="revision_id_value", - version_tag="version_tag_value", - display_name="display_name_value", - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) - ) - await client.update_phrase_matcher(request=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdatePhraseMatcherRequest() + jsonified_request["parent"] = "parent_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_calculate_stats_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.calculate_stats), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.CalculateStatsResponse( - average_turn_count=1931, - conversation_count=1955, - ) - ) - await client.calculate_stats(request=None) + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CalculateStatsRequest() + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) - assert args[0] == request_msg + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_analysis(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_settings_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_analysis_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_settings), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Settings( - name="name_value", - language_code="language_code_value", + unset_fields = transport.create_analysis._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "analysis", ) ) - await client.get_settings(request=None) + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetSettingsRequest() - assert args[0] == request_msg +def test_create_analysis_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_settings_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_settings), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Settings( - name="name_value", - language_code="language_code_value", - ) + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + analysis=resources.Analysis(name="name_value"), ) - await client.update_settings(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateSettingsRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.create_analysis(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_encryption_spec_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_analysis_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.EncryptionSpec( - name="name_value", - kms_key="kms_key_value", - ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_analysis( + contact_center_insights.CreateAnalysisRequest(), + parent="parent_value", + analysis=resources.Analysis(name="name_value"), ) - await client.get_encryption_spec(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetEncryptionSpecRequest() - assert args[0] == request_msg +def test_get_analysis_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_initialize_encryption_spec_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert client._transport.get_analysis in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) - await client.initialize_encryption_spec(request=None) + client._transport._wrapped_methods[client._transport.get_analysis] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.InitializeEncryptionSpecRequest() + request = {} + client.get_analysis(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.get_analysis(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_view_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_analysis_rest_required_fields( + request_type=contact_center_insights.GetAnalysisRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", - ) - ) - await client.create_view(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateViewRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_view_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", - ) - ) - await client.get_view(request=None) + # Designate an appropriate value for the returned response. + return_value = resources.Analysis() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetViewRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = resources.Analysis.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_views_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + response = client.get_analysis(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_analysis_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListViewsResponse( - next_page_token="next_page_token_value", - ) + unset_fields = transport.get_analysis._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_analysis_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Analysis() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", ) - await client.list_views(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListViewsRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Analysis.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.get_analysis(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_view_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_analysis_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", - ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_analysis( + contact_center_insights.GetAnalysisRequest(), + name="name_value", ) - await client.update_view(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateViewRequest() - assert args[0] == request_msg +def test_list_analyses_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_view_empty_call_grpc_asyncio(): - client = ContactCenterInsightsAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert client._transport.list_analyses in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_view(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_analyses] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteViewRequest() + request = {} + client.list_analyses(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.list_analyses(request) -def test_transport_kind_rest(): - transport = ContactCenterInsightsClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -def test_create_conversation_rest_bad_request( - request_type=contact_center_insights.CreateConversationRequest, +def test_list_analyses_rest_required_fields( + request_type=contact_center_insights.ListAnalysesRequest, ): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.create_conversation(request) + # verify fields with default values are dropped + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_analyses._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) -@pytest.mark.parametrize( - "request_type", - [ - contact_center_insights.CreateConversationRequest, - dict, - ], -) + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_analyses._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_analyses(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_analyses_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_analyses._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_analyses_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_analyses(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" + % client.transport._host, + args[1], + ) + + +def test_list_analyses_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_analyses( + contact_center_insights.ListAnalysesRequest(), + parent="parent_value", + ) + + +def test_list_analyses_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token="def", + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListAnalysesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + + pager = client.list_analyses(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Analysis) for i in results) + + pages = list(client.list_analyses(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_delete_analysis_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_analysis in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_analysis] = mock_rpc + + request = {} + client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_analysis(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_analysis_rest_required_fields( + request_type=contact_center_insights.DeleteAnalysisRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_analysis(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_analysis_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_analysis._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_analysis_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_analysis(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_analysis_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_analysis( + contact_center_insights.DeleteAnalysisRequest(), + name="name_value", + ) + + +def test_bulk_analyze_conversations_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.bulk_analyze_conversations + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.bulk_analyze_conversations + ] = mock_rpc + + request = {} + client.bulk_analyze_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.bulk_analyze_conversations(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_bulk_analyze_conversations_rest_required_fields( + request_type=contact_center_insights.BulkAnalyzeConversationsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["filter"] = "" + request_init["analysis_percentage"] = 0.0 + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + jsonified_request["filter"] = "filter_value" + jsonified_request["analysisPercentage"] = 0.20170000000000002 + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "filter" in jsonified_request + assert jsonified_request["filter"] == "filter_value" + assert "analysisPercentage" in jsonified_request + assert jsonified_request["analysisPercentage"] == 0.20170000000000002 + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.bulk_analyze_conversations(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_bulk_analyze_conversations_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.bulk_analyze_conversations._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "filter", + "analysisPercentage", + ) + ) + ) + + +def test_bulk_analyze_conversations_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + filter="filter_value", + analysis_percentage=0.20170000000000002, + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.bulk_analyze_conversations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/conversations:bulkAnalyze" + % client.transport._host, + args[1], + ) + + +def test_bulk_analyze_conversations_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_analyze_conversations( + contact_center_insights.BulkAnalyzeConversationsRequest(), + parent="parent_value", + filter="filter_value", + analysis_percentage=0.20170000000000002, + ) + + +def test_bulk_delete_conversations_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.bulk_delete_conversations + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.bulk_delete_conversations + ] = mock_rpc + + request = {} + client.bulk_delete_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.bulk_delete_conversations(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_bulk_delete_conversations_rest_required_fields( + request_type=contact_center_insights.BulkDeleteConversationsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_delete_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_delete_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.bulk_delete_conversations(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_bulk_delete_conversations_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.bulk_delete_conversations._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_bulk_delete_conversations_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + filter="filter_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.bulk_delete_conversations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/conversations:bulkDelete" + % client.transport._host, + args[1], + ) + + +def test_bulk_delete_conversations_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_delete_conversations( + contact_center_insights.BulkDeleteConversationsRequest(), + parent="parent_value", + filter="filter_value", + ) + + +def test_ingest_conversations_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.ingest_conversations in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.ingest_conversations + ] = mock_rpc + + request = {} + client.ingest_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.ingest_conversations(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_ingest_conversations_rest_required_fields( + request_type=contact_center_insights.IngestConversationsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).ingest_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).ingest_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.ingest_conversations(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_ingest_conversations_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.ingest_conversations._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_ingest_conversations_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.ingest_conversations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/conversations:ingest" + % client.transport._host, + args[1], + ) + + +def test_ingest_conversations_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.ingest_conversations( + contact_center_insights.IngestConversationsRequest(), + parent="parent_value", + ) + + +def test_export_insights_data_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.export_insights_data in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.export_insights_data + ] = mock_rpc + + request = {} + client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.export_insights_data(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_export_insights_data_rest_required_fields( + request_type=contact_center_insights.ExportInsightsDataRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_insights_data._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_insights_data._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.export_insights_data(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_export_insights_data_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.export_insights_data._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_export_insights_data_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.export_insights_data(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/insightsdata:export" + % client.transport._host, + args[1], + ) + + +def test_export_insights_data_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.export_insights_data( + contact_center_insights.ExportInsightsDataRequest(), + parent="parent_value", + ) + + +def test_create_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_issue_model in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_issue_model + ] = mock_rpc + + request = {} + client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_issue_model_rest_required_fields( + request_type=contact_center_insights.CreateIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "issueModel", + ) + ) + ) + + +def test_create_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + issue_model=resources.IssueModel(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/issueModels" + % client.transport._host, + args[1], + ) + + +def test_create_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent="parent_value", + issue_model=resources.IssueModel(name="name_value"), + ) + + +def test_update_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_issue_model in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_issue_model + ] = mock_rpc + + request = {} + client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_issue_model_rest_required_fields( + request_type=contact_center_insights.UpdateIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue_model._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("issueModel",))) + + +def test_update_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + + # get arguments that satisfy an http rule for this method + sample_request = { + "issue_model": { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + issue_model=resources.IssueModel(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{issue_model.name=projects/*/locations/*/issueModels/*}" + % client.transport._host, + args[1], + ) + + +def test_update_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_get_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_issue_model in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_issue_model] = mock_rpc + + request = {} + client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_issue_model_rest_required_fields( + request_type=contact_center_insights.GetIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/issueModels/*}" + % client.transport._host, + args[1], + ) + + +def test_get_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue_model( + contact_center_insights.GetIssueModelRequest(), + name="name_value", + ) + + +def test_list_issue_models_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_issue_models in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_issue_models + ] = mock_rpc + + request = {} + client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_issue_models(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_issue_models_rest_required_fields( + request_type=contact_center_insights.ListIssueModelsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issue_models._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issue_models._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssueModelsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListIssueModelsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_issue_models(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_issue_models_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_issue_models._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_list_issue_models_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssueModelsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_issue_models(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/issueModels" + % client.transport._host, + args[1], + ) + + +def test_list_issue_models_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), + parent="parent_value", + ) + + +def test_delete_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_issue_model in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_issue_model + ] = mock_rpc + + request = {} + client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_issue_model_rest_required_fields( + request_type=contact_center_insights.DeleteIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/issueModels/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue_model( + contact_center_insights.DeleteIssueModelRequest(), + name="name_value", + ) + + +def test_deploy_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.deploy_issue_model in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.deploy_issue_model + ] = mock_rpc + + request = {} + client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.deploy_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_deploy_issue_model_rest_required_fields( + request_type=contact_center_insights.DeployIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).deploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).deploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.deploy_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_deploy_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.deploy_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_deploy_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.deploy_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/issueModels/*}:deploy" + % client.transport._host, + args[1], + ) + + +def test_deploy_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), + name="name_value", + ) + + +def test_undeploy_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.undeploy_issue_model in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.undeploy_issue_model + ] = mock_rpc + + request = {} + client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.undeploy_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_undeploy_issue_model_rest_required_fields( + request_type=contact_center_insights.UndeployIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).undeploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).undeploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.undeploy_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_undeploy_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.undeploy_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_undeploy_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.undeploy_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/issueModels/*}:undeploy" + % client.transport._host, + args[1], + ) + + +def test_undeploy_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), + name="name_value", + ) + + +def test_export_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.export_issue_model in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.export_issue_model + ] = mock_rpc + + request = {} + client.export_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.export_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_export_issue_model_rest_required_fields( + request_type=contact_center_insights.ExportIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.export_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_export_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.export_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_export_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.export_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/issueModels/*}:export" + % client.transport._host, + args[1], + ) + + +def test_export_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.export_issue_model( + contact_center_insights.ExportIssueModelRequest(), + name="name_value", + ) + + +def test_import_issue_model_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.import_issue_model in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.import_issue_model + ] = mock_rpc + + request = {} + client.import_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.import_issue_model(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_import_issue_model_rest_required_fields( + request_type=contact_center_insights.ImportIssueModelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).import_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).import_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.import_issue_model(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_import_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.import_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_import_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.import_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/issueModels:import" + % client.transport._host, + args[1], + ) + + +def test_import_issue_model_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.import_issue_model( + contact_center_insights.ImportIssueModelRequest(), + parent="parent_value", + ) + + +def test_get_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_issue] = mock_rpc + + request = {} + client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_issue_rest_required_fields( + request_type=contact_center_insights.GetIssueRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_issue_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_issue_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" + % client.transport._host, + args[1], + ) + + +def test_get_issue_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue( + contact_center_insights.GetIssueRequest(), + name="name_value", + ) + + +def test_list_issues_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_issues in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_issues] = mock_rpc + + request = {} + client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_issues(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_issues_rest_required_fields( + request_type=contact_center_insights.ListIssuesRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issues._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issues._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssuesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_issues(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_issues_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_issues._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_list_issues_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssuesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/issueModels/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_issues(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/issueModels/*}/issues" + % client.transport._host, + args[1], + ) + + +def test_list_issues_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issues( + contact_center_insights.ListIssuesRequest(), + parent="parent_value", + ) + + +def test_update_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_issue] = mock_rpc + + request = {} + client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_issue_rest_required_fields( + request_type=contact_center_insights.UpdateIssueRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_issue_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("issue",))) + + +def test_update_issue_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + + # get arguments that satisfy an http rule for this method + sample_request = { + "issue": { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + issue=resources.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}" + % client.transport._host, + args[1], + ) + + +def test_update_issue_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_issue] = mock_rpc + + request = {} + client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_issue_rest_required_fields( + request_type=contact_center_insights.DeleteIssueRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_issue_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_issue_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_issue_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue( + contact_center_insights.DeleteIssueRequest(), + name="name_value", + ) + + +def test_calculate_issue_model_stats_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.calculate_issue_model_stats + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.calculate_issue_model_stats + ] = mock_rpc + + request = {} + client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.calculate_issue_model_stats(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_calculate_issue_model_stats_rest_required_fields( + request_type=contact_center_insights.CalculateIssueModelStatsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["issue_model"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["issueModel"] = "issue_model_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "issueModel" in jsonified_request + assert jsonified_request["issueModel"] == "issue_model_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateIssueModelStatsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.calculate_issue_model_stats(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_calculate_issue_model_stats_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.calculate_issue_model_stats._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("issueModel",))) + + +def test_calculate_issue_model_stats_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateIssueModelStatsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "issue_model": "projects/sample1/locations/sample2/issueModels/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + issue_model="issue_model_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.calculate_issue_model_stats(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats" + % client.transport._host, + args[1], + ) + + +def test_calculate_issue_model_stats_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.calculate_issue_model_stats( + contact_center_insights.CalculateIssueModelStatsRequest(), + issue_model="issue_model_value", + ) + + +def test_create_phrase_matcher_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_phrase_matcher + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_phrase_matcher + ] = mock_rpc + + request = {} + client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_phrase_matcher(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_phrase_matcher_rest_required_fields( + request_type=contact_center_insights.CreatePhraseMatcherRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_phrase_matcher(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "phraseMatcher", + ) + ) + ) + + +def test_create_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + phrase_matcher=resources.PhraseMatcher(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/phraseMatchers" + % client.transport._host, + args[1], + ) + + +def test_create_phrase_matcher_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_phrase_matcher( + contact_center_insights.CreatePhraseMatcherRequest(), + parent="parent_value", + phrase_matcher=resources.PhraseMatcher(name="name_value"), + ) + + +def test_get_phrase_matcher_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_phrase_matcher in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_phrase_matcher + ] = mock_rpc + + request = {} + client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_phrase_matcher(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_phrase_matcher_rest_required_fields( + request_type=contact_center_insights.GetPhraseMatcherRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_phrase_matcher(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" + % client.transport._host, + args[1], + ) + + +def test_get_phrase_matcher_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_phrase_matcher( + contact_center_insights.GetPhraseMatcherRequest(), + name="name_value", + ) + + +def test_list_phrase_matchers_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_phrase_matchers in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_phrase_matchers + ] = mock_rpc + + request = {} + client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_phrase_matchers(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_phrase_matchers_rest_required_fields( + request_type=contact_center_insights.ListPhraseMatchersRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_phrase_matchers._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_phrase_matchers._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListPhraseMatchersResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListPhraseMatchersResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_phrase_matchers(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_phrase_matchers_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_phrase_matchers._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_phrase_matchers_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListPhraseMatchersResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListPhraseMatchersResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_phrase_matchers(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/phraseMatchers" + % client.transport._host, + args[1], + ) + + +def test_list_phrase_matchers_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_phrase_matchers( + contact_center_insights.ListPhraseMatchersRequest(), + parent="parent_value", + ) + + +def test_list_phrase_matchers_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token="abc", + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token="def", + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListPhraseMatchersResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_phrase_matchers(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.PhraseMatcher) for i in results) + + pages = list(client.list_phrase_matchers(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_delete_phrase_matcher_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_phrase_matcher + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_phrase_matcher + ] = mock_rpc + + request = {} + client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_phrase_matcher(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_phrase_matcher_rest_required_fields( + request_type=contact_center_insights.DeletePhraseMatcherRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_phrase_matcher(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_phrase_matcher_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_phrase_matcher( + contact_center_insights.DeletePhraseMatcherRequest(), + name="name_value", + ) + + +def test_update_phrase_matcher_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_phrase_matcher + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_phrase_matcher + ] = mock_rpc + + request = {} + client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_phrase_matcher(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_phrase_matcher_rest_required_fields( + request_type=contact_center_insights.UpdatePhraseMatcherRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_phrase_matcher._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_phrase_matcher(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("phraseMatcher",))) + + +def test_update_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + + # get arguments that satisfy an http rule for this method + sample_request = { + "phrase_matcher": { + "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + phrase_matcher=resources.PhraseMatcher(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}" + % client.transport._host, + args[1], + ) + + +def test_update_phrase_matcher_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_phrase_matcher( + contact_center_insights.UpdatePhraseMatcherRequest(), + phrase_matcher=resources.PhraseMatcher(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_calculate_stats_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.calculate_stats in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.calculate_stats] = mock_rpc + + request = {} + client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.calculate_stats(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_calculate_stats_rest_required_fields( + request_type=contact_center_insights.CalculateStatsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["location"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).calculate_stats._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["location"] = "location_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).calculate_stats._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "location" in jsonified_request + assert jsonified_request["location"] == "location_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateStatsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.CalculateStatsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.calculate_stats(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_calculate_stats_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.calculate_stats._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter",)) & set(("location",))) + + +def test_calculate_stats_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateStatsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"location": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + location="location_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.calculate_stats(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{location=projects/*/locations/*}/conversations:calculateStats" + % client.transport._host, + args[1], + ) + + +def test_calculate_stats_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.calculate_stats( + contact_center_insights.CalculateStatsRequest(), + location="location_value", + ) + + +def test_get_settings_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_settings in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_settings] = mock_rpc + + request = {} + client.get_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_settings(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_settings_rest_required_fields( + request_type=contact_center_insights.GetSettingsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_settings(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_settings_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_settings._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_settings_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/settings"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_settings(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/settings}" % client.transport._host, + args[1], + ) + + +def test_get_settings_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_settings( + contact_center_insights.GetSettingsRequest(), + name="name_value", + ) + + +def test_update_settings_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_settings in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_settings] = mock_rpc + + request = {} + client.update_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_settings(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_settings_rest_required_fields( + request_type=contact_center_insights.UpdateSettingsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_settings._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_settings(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_settings_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_settings._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "settings", + "updateMask", + ) + ) + ) + + +def test_update_settings_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + + # get arguments that satisfy an http rule for this method + sample_request = { + "settings": {"name": "projects/sample1/locations/sample2/settings"} + } + + # get truthy value for each flattened field + mock_args = dict( + settings=resources.Settings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_settings(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{settings.name=projects/*/locations/*/settings}" + % client.transport._host, + args[1], + ) + + +def test_update_settings_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_settings( + contact_center_insights.UpdateSettingsRequest(), + settings=resources.Settings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_create_analysis_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_analysis_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_analysis_rule + ] = mock_rpc + + request = {} + client.create_analysis_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_analysis_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_analysis_rule_rest_required_fields( + request_type=contact_center_insights.CreateAnalysisRuleRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_analysis_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_analysis_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.AnalysisRule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.AnalysisRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_analysis_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_analysis_rule_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_analysis_rule._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "analysisRule", + ) + ) + ) + + +def test_create_analysis_rule_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.AnalysisRule() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + analysis_rule=resources.AnalysisRule(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.AnalysisRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_analysis_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/analysisRules" + % client.transport._host, + args[1], + ) + + +def test_create_analysis_rule_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_analysis_rule( + contact_center_insights.CreateAnalysisRuleRequest(), + parent="parent_value", + analysis_rule=resources.AnalysisRule(name="name_value"), + ) + + +def test_get_analysis_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_analysis_rule in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_analysis_rule + ] = mock_rpc + + request = {} + client.get_analysis_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_analysis_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_analysis_rule_rest_required_fields( + request_type=contact_center_insights.GetAnalysisRuleRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_analysis_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_analysis_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.AnalysisRule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.AnalysisRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_analysis_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_analysis_rule_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_analysis_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_analysis_rule_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.AnalysisRule() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/analysisRules/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.AnalysisRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_analysis_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/analysisRules/*}" + % client.transport._host, + args[1], + ) + + +def test_get_analysis_rule_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_analysis_rule( + contact_center_insights.GetAnalysisRuleRequest(), + name="name_value", + ) + + +def test_list_analysis_rules_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_analysis_rules in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_analysis_rules + ] = mock_rpc + + request = {} + client.list_analysis_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_analysis_rules(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_analysis_rules_rest_required_fields( + request_type=contact_center_insights.ListAnalysisRulesRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_analysis_rules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_analysis_rules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysisRulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListAnalysisRulesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_analysis_rules(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_analysis_rules_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_analysis_rules._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_analysis_rules_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysisRulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListAnalysisRulesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_analysis_rules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/analysisRules" + % client.transport._host, + args[1], + ) + + +def test_list_analysis_rules_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_analysis_rules( + contact_center_insights.ListAnalysisRulesRequest(), + parent="parent_value", + ) + + +def test_list_analysis_rules_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[], + next_page_token="def", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAnalysisRulesResponse( + analysis_rules=[ + resources.AnalysisRule(), + resources.AnalysisRule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListAnalysisRulesResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_analysis_rules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.AnalysisRule) for i in results) + + pages = list(client.list_analysis_rules(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_update_analysis_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_analysis_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_analysis_rule + ] = mock_rpc + + request = {} + client.update_analysis_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_analysis_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_analysis_rule_rest_required_fields( + request_type=contact_center_insights.UpdateAnalysisRuleRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_analysis_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_analysis_rule._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.AnalysisRule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.AnalysisRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_analysis_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_analysis_rule_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_analysis_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("analysisRule",))) + + +def test_update_analysis_rule_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.AnalysisRule() + + # get arguments that satisfy an http rule for this method + sample_request = { + "analysis_rule": { + "name": "projects/sample1/locations/sample2/analysisRules/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + analysis_rule=resources.AnalysisRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.AnalysisRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_analysis_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{analysis_rule.name=projects/*/locations/*/analysisRules/*}" + % client.transport._host, + args[1], + ) + + +def test_update_analysis_rule_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_analysis_rule( + contact_center_insights.UpdateAnalysisRuleRequest(), + analysis_rule=resources.AnalysisRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_analysis_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_analysis_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_analysis_rule + ] = mock_rpc + + request = {} + client.delete_analysis_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_analysis_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_analysis_rule_rest_required_fields( + request_type=contact_center_insights.DeleteAnalysisRuleRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_analysis_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_analysis_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_analysis_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_analysis_rule_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_analysis_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_analysis_rule_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/analysisRules/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_analysis_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/analysisRules/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_analysis_rule_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_analysis_rule( + contact_center_insights.DeleteAnalysisRuleRequest(), + name="name_value", + ) + + +def test_get_encryption_spec_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_encryption_spec in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_encryption_spec + ] = mock_rpc + + request = {} + client.get_encryption_spec(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_encryption_spec(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_encryption_spec_rest_required_fields( + request_type=contact_center_insights.GetEncryptionSpecRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_encryption_spec._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_encryption_spec._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.EncryptionSpec() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.EncryptionSpec.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_encryption_spec(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_encryption_spec_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_encryption_spec._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_encryption_spec_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.EncryptionSpec() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/encryptionSpec"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.EncryptionSpec.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_encryption_spec(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/encryptionSpec}" + % client.transport._host, + args[1], + ) + + +def test_get_encryption_spec_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_encryption_spec( + contact_center_insights.GetEncryptionSpecRequest(), + name="name_value", + ) + + +def test_initialize_encryption_spec_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.initialize_encryption_spec + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.initialize_encryption_spec + ] = mock_rpc + + request = {} + client.initialize_encryption_spec(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.initialize_encryption_spec(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_initialize_encryption_spec_rest_required_fields( + request_type=contact_center_insights.InitializeEncryptionSpecRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).initialize_encryption_spec._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).initialize_encryption_spec._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.initialize_encryption_spec(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_initialize_encryption_spec_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.initialize_encryption_spec._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("encryptionSpec",))) + + +def test_initialize_encryption_spec_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "encryption_spec": { + "name": "projects/sample1/locations/sample2/encryptionSpec" + } + } + + # get truthy value for each flattened field + mock_args = dict( + encryption_spec=resources.EncryptionSpec(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.initialize_encryption_spec(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{encryption_spec.name=projects/*/locations/*/encryptionSpec}:initialize" + % client.transport._host, + args[1], + ) + + +def test_initialize_encryption_spec_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.initialize_encryption_spec( + contact_center_insights.InitializeEncryptionSpecRequest(), + encryption_spec=resources.EncryptionSpec(name="name_value"), + ) + + +def test_create_view_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_view in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_view] = mock_rpc + + request = {} + client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_view(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_view_rest_required_fields( + request_type=contact_center_insights.CreateViewRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.View() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_view(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_view._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "view", + ) + ) + ) + + +def test_create_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.View() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + view=resources.View(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, + args[1], + ) + + +def test_create_view_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_view( + contact_center_insights.CreateViewRequest(), + parent="parent_value", + view=resources.View(name="name_value"), + ) + + +def test_get_view_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_view in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_view] = mock_rpc + + request = {} + client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_view(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_view_rest_required_fields( + request_type=contact_center_insights.GetViewRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.View() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_view(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_view._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.View() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/views/sample3"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, + args[1], + ) + + +def test_get_view_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_view( + contact_center_insights.GetViewRequest(), + name="name_value", + ) + + +def test_list_views_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_views in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_views] = mock_rpc + + request = {} + client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_views(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_views_rest_required_fields( + request_type=contact_center_insights.ListViewsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_views._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_views._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListViewsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListViewsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_views(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_views_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_views._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_views_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListViewsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListViewsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_views(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, + args[1], + ) + + +def test_list_views_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_views( + contact_center_insights.ListViewsRequest(), + parent="parent_value", + ) + + +def test_list_views_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token="abc", + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token="def", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListViewsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_views(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.View) for i in results) + + pages = list(client.list_views(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_update_view_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_view in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_view] = mock_rpc + + request = {} + client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_view(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_view_rest_required_fields( + request_type=contact_center_insights.UpdateViewRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_view._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.View() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_view(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_view._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("view",))) + + +def test_update_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.View() + + # get arguments that satisfy an http rule for this method + sample_request = { + "view": {"name": "projects/sample1/locations/sample2/views/sample3"} + } + + # get truthy value for each flattened field + mock_args = dict( + view=resources.View(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{view.name=projects/*/locations/*/views/*}" % client.transport._host, + args[1], + ) + + +def test_update_view_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_view_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_view in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_view] = mock_rpc + + request = {} + client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_view(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_view_rest_required_fields( + request_type=contact_center_insights.DeleteViewRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_view(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_view._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/views/sample3"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, + args[1], + ) + + +def test_delete_view_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_view( + contact_center_insights.DeleteViewRequest(), + name="name_value", + ) + + +def test_query_metrics_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.query_metrics in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.query_metrics] = mock_rpc + + request = {} + client.query_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.query_metrics(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_query_metrics_rest_required_fields( + request_type=contact_center_insights.QueryMetricsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["location"] = "" + request_init["filter"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).query_metrics._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["location"] = "location_value" + jsonified_request["filter"] = "filter_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).query_metrics._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "location" in jsonified_request + assert jsonified_request["location"] == "location_value" + assert "filter" in jsonified_request + assert jsonified_request["filter"] == "filter_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.query_metrics(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_query_metrics_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.query_metrics._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "location", + "filter", + ) + ) + ) + + +def test_create_qa_question_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_qa_question in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_qa_question + ] = mock_rpc + + request = {} + client.create_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_qa_question_rest_required_fields( + request_type=contact_center_insights.CreateQaQuestionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_qa_question._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_qa_question._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("qa_question_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaQuestion() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_qa_question(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_qa_question_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_qa_question._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("qaQuestionId",)) + & set( + ( + "parent", + "qaQuestion", + ) + ) + ) + + +def test_create_qa_question_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaQuestion() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + qa_question=resources.QaQuestion(name="name_value"), + qa_question_id="qa_question_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_qa_question(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/qaScorecards/*/revisions/*}/qaQuestions" + % client.transport._host, + args[1], + ) + + +def test_create_qa_question_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_qa_question( + contact_center_insights.CreateQaQuestionRequest(), + parent="parent_value", + qa_question=resources.QaQuestion(name="name_value"), + qa_question_id="qa_question_id_value", + ) + + +def test_get_qa_question_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_qa_question in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_qa_question] = mock_rpc + + request = {} + client.get_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_qa_question_rest_required_fields( + request_type=contact_center_insights.GetQaQuestionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_qa_question._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_qa_question._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaQuestion() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_qa_question(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_qa_question_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_qa_question._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_qa_question_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaQuestion() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_qa_question(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*/qaQuestions/*}" + % client.transport._host, + args[1], + ) + + +def test_get_qa_question_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_qa_question( + contact_center_insights.GetQaQuestionRequest(), + name="name_value", + ) + + +def test_update_qa_question_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_qa_question in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_qa_question + ] = mock_rpc + + request = {} + client.update_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_qa_question_rest_required_fields( + request_type=contact_center_insights.UpdateQaQuestionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_qa_question._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_qa_question._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaQuestion() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_qa_question(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_qa_question_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_qa_question._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "qaQuestion", + "updateMask", + ) + ) + ) + + +def test_update_qa_question_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaQuestion() + + # get arguments that satisfy an http rule for this method + sample_request = { + "qa_question": { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" + } + } + + # get truthy value for each flattened field + mock_args = dict( + qa_question=resources.QaQuestion(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_qa_question(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{qa_question.name=projects/*/locations/*/qaScorecards/*/revisions/*/qaQuestions/*}" + % client.transport._host, + args[1], + ) + + +def test_update_qa_question_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_qa_question( + contact_center_insights.UpdateQaQuestionRequest(), + qa_question=resources.QaQuestion(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_qa_question_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_qa_question in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_qa_question + ] = mock_rpc + + request = {} + client.delete_qa_question(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_qa_question(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_qa_question_rest_required_fields( + request_type=contact_center_insights.DeleteQaQuestionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_qa_question._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_qa_question._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_qa_question(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_qa_question_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_qa_question._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_qa_question_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_qa_question(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*/qaQuestions/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_qa_question_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_qa_question( + contact_center_insights.DeleteQaQuestionRequest(), + name="name_value", + ) + + +def test_list_qa_questions_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_qa_questions in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_qa_questions + ] = mock_rpc + + request = {} + client.list_qa_questions(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_qa_questions(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_qa_questions_rest_required_fields( + request_type=contact_center_insights.ListQaQuestionsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_qa_questions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_qa_questions._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListQaQuestionsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListQaQuestionsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_qa_questions(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_qa_questions_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_qa_questions._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_qa_questions_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListQaQuestionsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListQaQuestionsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_qa_questions(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/qaScorecards/*/revisions/*}/qaQuestions" + % client.transport._host, + args[1], + ) + + +def test_list_qa_questions_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_qa_questions( + contact_center_insights.ListQaQuestionsRequest(), + parent="parent_value", + ) + + +def test_list_qa_questions_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + resources.QaQuestion(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[], + next_page_token="def", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaQuestionsResponse( + qa_questions=[ + resources.QaQuestion(), + resources.QaQuestion(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListQaQuestionsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + + pager = client.list_qa_questions(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.QaQuestion) for i in results) + + pages = list(client.list_qa_questions(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_qa_scorecard_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_qa_scorecard in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_qa_scorecard + ] = mock_rpc + + request = {} + client.create_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_qa_scorecard(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_qa_scorecard_rest_required_fields( + request_type=contact_center_insights.CreateQaScorecardRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_qa_scorecard._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_qa_scorecard._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("qa_scorecard_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecard() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecard.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_qa_scorecard(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_qa_scorecard_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_qa_scorecard._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("qaScorecardId",)) + & set( + ( + "parent", + "qaScorecard", + ) + ) + ) + + +def test_create_qa_scorecard_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecard() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + qa_scorecard=resources.QaScorecard(name="name_value"), + qa_scorecard_id="qa_scorecard_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaScorecard.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_qa_scorecard(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/qaScorecards" + % client.transport._host, + args[1], + ) + + +def test_create_qa_scorecard_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_qa_scorecard( + contact_center_insights.CreateQaScorecardRequest(), + parent="parent_value", + qa_scorecard=resources.QaScorecard(name="name_value"), + qa_scorecard_id="qa_scorecard_id_value", + ) + + +def test_get_qa_scorecard_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_qa_scorecard in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_qa_scorecard + ] = mock_rpc + + request = {} + client.get_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_qa_scorecard(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_qa_scorecard_rest_required_fields( + request_type=contact_center_insights.GetQaScorecardRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_qa_scorecard._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_qa_scorecard._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecard() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecard.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_qa_scorecard(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_qa_scorecard_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_qa_scorecard._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_qa_scorecard_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecard() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaScorecard.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_qa_scorecard(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/qaScorecards/*}" + % client.transport._host, + args[1], + ) + + +def test_get_qa_scorecard_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_qa_scorecard( + contact_center_insights.GetQaScorecardRequest(), + name="name_value", + ) + + +def test_update_qa_scorecard_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_qa_scorecard in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_qa_scorecard + ] = mock_rpc + + request = {} + client.update_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_qa_scorecard(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_qa_scorecard_rest_required_fields( + request_type=contact_center_insights.UpdateQaScorecardRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_qa_scorecard._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_qa_scorecard._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecard() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecard.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_qa_scorecard(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_qa_scorecard_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_qa_scorecard._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "qaScorecard", + "updateMask", + ) + ) + ) + + +def test_update_qa_scorecard_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecard() + + # get arguments that satisfy an http rule for this method + sample_request = { + "qa_scorecard": { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + qa_scorecard=resources.QaScorecard(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaScorecard.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_qa_scorecard(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{qa_scorecard.name=projects/*/locations/*/qaScorecards/*}" + % client.transport._host, + args[1], + ) + + +def test_update_qa_scorecard_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_qa_scorecard( + contact_center_insights.UpdateQaScorecardRequest(), + qa_scorecard=resources.QaScorecard(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_qa_scorecard_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_qa_scorecard in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_qa_scorecard + ] = mock_rpc + + request = {} + client.delete_qa_scorecard(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_qa_scorecard(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_qa_scorecard_rest_required_fields( + request_type=contact_center_insights.DeleteQaScorecardRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_qa_scorecard._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_qa_scorecard._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("force",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_qa_scorecard(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_qa_scorecard_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_qa_scorecard._get_unset_required_fields({}) + assert set(unset_fields) == (set(("force",)) & set(("name",))) + + +def test_delete_qa_scorecard_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_qa_scorecard(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/qaScorecards/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_qa_scorecard_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_qa_scorecard( + contact_center_insights.DeleteQaScorecardRequest(), + name="name_value", + ) + + +def test_list_qa_scorecards_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_qa_scorecards in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_qa_scorecards + ] = mock_rpc + + request = {} + client.list_qa_scorecards(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_qa_scorecards(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_qa_scorecards_rest_required_fields( + request_type=contact_center_insights.ListQaScorecardsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_qa_scorecards._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_qa_scorecards._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListQaScorecardsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListQaScorecardsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_qa_scorecards(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_qa_scorecards_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_qa_scorecards._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_qa_scorecards_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListQaScorecardsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListQaScorecardsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_qa_scorecards(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/qaScorecards" + % client.transport._host, + args[1], + ) + + +def test_list_qa_scorecards_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_qa_scorecards( + contact_center_insights.ListQaScorecardsRequest(), + parent="parent_value", + ) + + +def test_list_qa_scorecards_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + resources.QaScorecard(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardsResponse( + qa_scorecards=[ + resources.QaScorecard(), + resources.QaScorecard(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListQaScorecardsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_qa_scorecards(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.QaScorecard) for i in results) + + pages = list(client.list_qa_scorecards(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_qa_scorecard_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_qa_scorecard_revision + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_qa_scorecard_revision + ] = mock_rpc + + request = {} + client.create_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_qa_scorecard_revision_rest_required_fields( + request_type=contact_center_insights.CreateQaScorecardRevisionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("qa_scorecard_revision_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecardRevision() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_qa_scorecard_revision(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_qa_scorecard_revision_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_qa_scorecard_revision._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("qaScorecardRevisionId",)) + & set( + ( + "parent", + "qaScorecardRevision", + ) + ) + ) + + +def test_create_qa_scorecard_revision_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecardRevision() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + qa_scorecard_revision=resources.QaScorecardRevision(name="name_value"), + qa_scorecard_revision_id="qa_scorecard_revision_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_qa_scorecard_revision(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/qaScorecards/*}/revisions" + % client.transport._host, + args[1], + ) + + +def test_create_qa_scorecard_revision_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_qa_scorecard_revision( + contact_center_insights.CreateQaScorecardRevisionRequest(), + parent="parent_value", + qa_scorecard_revision=resources.QaScorecardRevision(name="name_value"), + qa_scorecard_revision_id="qa_scorecard_revision_id_value", + ) + + +def test_get_qa_scorecard_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_qa_scorecard_revision + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_qa_scorecard_revision + ] = mock_rpc + + request = {} + client.get_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_qa_scorecard_revision_rest_required_fields( + request_type=contact_center_insights.GetQaScorecardRevisionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecardRevision() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_qa_scorecard_revision(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_qa_scorecard_revision_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_qa_scorecard_revision._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_qa_scorecard_revision_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecardRevision() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_qa_scorecard_revision(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*}" + % client.transport._host, + args[1], + ) + + +def test_get_qa_scorecard_revision_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_qa_scorecard_revision( + contact_center_insights.GetQaScorecardRevisionRequest(), + name="name_value", + ) + + +def test_tune_qa_scorecard_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.tune_qa_scorecard_revision + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.tune_qa_scorecard_revision + ] = mock_rpc + + request = {} + client.tune_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.tune_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_tune_qa_scorecard_revision_rest_required_fields( + request_type=contact_center_insights.TuneQaScorecardRevisionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["filter"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).tune_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + jsonified_request["filter"] = "filter_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).tune_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "filter" in jsonified_request + assert jsonified_request["filter"] == "filter_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.tune_qa_scorecard_revision(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_tune_qa_scorecard_revision_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.tune_qa_scorecard_revision._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "filter", + ) + ) + ) + + +def test_tune_qa_scorecard_revision_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + filter="filter_value", + validate_only=True, + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.tune_qa_scorecard_revision(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/qaScorecards/*/revisions/*}:tuneQaScorecardRevision" + % client.transport._host, + args[1], + ) + + +def test_tune_qa_scorecard_revision_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.tune_qa_scorecard_revision( + contact_center_insights.TuneQaScorecardRevisionRequest(), + parent="parent_value", + filter="filter_value", + validate_only=True, + ) + + +def test_deploy_qa_scorecard_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.deploy_qa_scorecard_revision + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.deploy_qa_scorecard_revision + ] = mock_rpc + + request = {} + client.deploy_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.deploy_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_deploy_qa_scorecard_revision_rest_required_fields( + request_type=contact_center_insights.DeployQaScorecardRevisionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).deploy_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).deploy_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecardRevision() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.deploy_qa_scorecard_revision(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_deploy_qa_scorecard_revision_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.deploy_qa_scorecard_revision._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_undeploy_qa_scorecard_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.undeploy_qa_scorecard_revision + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.undeploy_qa_scorecard_revision + ] = mock_rpc + + request = {} + client.undeploy_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.undeploy_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_undeploy_qa_scorecard_revision_rest_required_fields( + request_type=contact_center_insights.UndeployQaScorecardRevisionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).undeploy_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).undeploy_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.QaScorecardRevision() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.undeploy_qa_scorecard_revision(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_undeploy_qa_scorecard_revision_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.undeploy_qa_scorecard_revision._get_unset_required_fields( + {} + ) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_qa_scorecard_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_qa_scorecard_revision + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_qa_scorecard_revision + ] = mock_rpc + + request = {} + client.delete_qa_scorecard_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_qa_scorecard_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_qa_scorecard_revision_rest_required_fields( + request_type=contact_center_insights.DeleteQaScorecardRevisionRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_qa_scorecard_revision._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("force",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_qa_scorecard_revision(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_qa_scorecard_revision_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_qa_scorecard_revision._get_unset_required_fields({}) + assert set(unset_fields) == (set(("force",)) & set(("name",))) + + +def test_delete_qa_scorecard_revision_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_qa_scorecard_revision(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/qaScorecards/*/revisions/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_qa_scorecard_revision_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_qa_scorecard_revision( + contact_center_insights.DeleteQaScorecardRevisionRequest(), + name="name_value", + ) + + +def test_list_qa_scorecard_revisions_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_qa_scorecard_revisions + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_qa_scorecard_revisions + ] = mock_rpc + + request = {} + client.list_qa_scorecard_revisions(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_qa_scorecard_revisions(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_qa_scorecard_revisions_rest_required_fields( + request_type=contact_center_insights.ListQaScorecardRevisionsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_qa_scorecard_revisions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_qa_scorecard_revisions._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListQaScorecardRevisionsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListQaScorecardRevisionsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_qa_scorecard_revisions(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_qa_scorecard_revisions_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_qa_scorecard_revisions._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_qa_scorecard_revisions_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListQaScorecardRevisionsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListQaScorecardRevisionsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_qa_scorecard_revisions(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/qaScorecards/*}/revisions" + % client.transport._host, + args[1], + ) + + +def test_list_qa_scorecard_revisions_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_qa_scorecard_revisions( + contact_center_insights.ListQaScorecardRevisionsRequest(), + parent="parent_value", + ) + + +def test_list_qa_scorecard_revisions_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + next_page_token="abc", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[], + next_page_token="def", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListQaScorecardRevisionsResponse( + qa_scorecard_revisions=[ + resources.QaScorecardRevision(), + resources.QaScorecardRevision(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListQaScorecardRevisionsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + + pager = client.list_qa_scorecard_revisions(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.QaScorecardRevision) for i in results) + + pages = list(client.list_qa_scorecard_revisions(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_feedback_label_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_feedback_label + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_feedback_label + ] = mock_rpc + + request = {} + client.create_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_feedback_label(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_feedback_label_rest_required_fields( + request_type=contact_center_insights.CreateFeedbackLabelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_feedback_label._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_feedback_label._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("feedback_label_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.FeedbackLabel() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.FeedbackLabel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_feedback_label(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_feedback_label_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_feedback_label._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("feedbackLabelId",)) + & set( + ( + "parent", + "feedbackLabel", + ) + ) + ) + + +def test_create_feedback_label_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.FeedbackLabel() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + feedback_label=resources.FeedbackLabel(label="label_value"), + feedback_label_id="feedback_label_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.FeedbackLabel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_feedback_label(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/conversations/*}/feedbackLabels" + % client.transport._host, + args[1], + ) + + +def test_create_feedback_label_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_feedback_label( + contact_center_insights.CreateFeedbackLabelRequest(), + parent="parent_value", + feedback_label=resources.FeedbackLabel(label="label_value"), + feedback_label_id="feedback_label_id_value", + ) + + +def test_list_feedback_labels_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_feedback_labels in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_feedback_labels + ] = mock_rpc + + request = {} + client.list_feedback_labels(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_feedback_labels(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_feedback_labels_rest_required_fields( + request_type=contact_center_insights.ListFeedbackLabelsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_feedback_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_feedback_labels._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListFeedbackLabelsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListFeedbackLabelsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_feedback_labels(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_feedback_labels_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_feedback_labels._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_feedback_labels_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListFeedbackLabelsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListFeedbackLabelsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_feedback_labels(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/conversations/*}/feedbackLabels" + % client.transport._host, + args[1], + ) + + +def test_list_feedback_labels_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_feedback_labels( + contact_center_insights.ListFeedbackLabelsRequest(), + parent="parent_value", + ) + + +def test_list_feedback_labels_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListFeedbackLabelsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + + pager = client.list_feedback_labels(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.FeedbackLabel) for i in results) + + pages = list(client.list_feedback_labels(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_feedback_label_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_feedback_label in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_feedback_label + ] = mock_rpc + + request = {} + client.get_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_feedback_label(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_feedback_label_rest_required_fields( + request_type=contact_center_insights.GetFeedbackLabelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_feedback_label._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_feedback_label._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.FeedbackLabel() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.FeedbackLabel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_feedback_label(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_feedback_label_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_feedback_label._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_feedback_label_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.FeedbackLabel() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.FeedbackLabel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_feedback_label(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/conversations/*/feedbackLabels/*}" + % client.transport._host, + args[1], + ) + + +def test_get_feedback_label_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_feedback_label( + contact_center_insights.GetFeedbackLabelRequest(), + name="name_value", + ) + + +def test_update_feedback_label_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_feedback_label + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_feedback_label + ] = mock_rpc + + request = {} + client.update_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_feedback_label(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_feedback_label_rest_required_fields( + request_type=contact_center_insights.UpdateFeedbackLabelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_feedback_label._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_feedback_label._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.FeedbackLabel() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.FeedbackLabel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_feedback_label(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_feedback_label_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_feedback_label._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "feedbackLabel", + "updateMask", + ) + ) + ) + + +def test_update_feedback_label_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.FeedbackLabel() + + # get arguments that satisfy an http rule for this method + sample_request = { + "feedback_label": { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + feedback_label=resources.FeedbackLabel(label="label_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = resources.FeedbackLabel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_feedback_label(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{feedback_label.name=projects/*/locations/*/conversations/*/feedbackLabels/*}" + % client.transport._host, + args[1], + ) + + +def test_update_feedback_label_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_feedback_label( + contact_center_insights.UpdateFeedbackLabelRequest(), + feedback_label=resources.FeedbackLabel(label="label_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_feedback_label_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_feedback_label + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_feedback_label + ] = mock_rpc + + request = {} + client.delete_feedback_label(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_feedback_label(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_feedback_label_rest_required_fields( + request_type=contact_center_insights.DeleteFeedbackLabelRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_feedback_label._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_feedback_label._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_feedback_label(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_feedback_label_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_feedback_label._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_feedback_label_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_feedback_label(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/conversations/*/feedbackLabels/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_feedback_label_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_feedback_label( + contact_center_insights.DeleteFeedbackLabelRequest(), + name="name_value", + ) + + +def test_list_all_feedback_labels_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_all_feedback_labels + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_all_feedback_labels + ] = mock_rpc + + request = {} + client.list_all_feedback_labels(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_all_feedback_labels(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_all_feedback_labels_rest_required_fields( + request_type=contact_center_insights.ListAllFeedbackLabelsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_all_feedback_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_all_feedback_labels._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAllFeedbackLabelsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListAllFeedbackLabelsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_all_feedback_labels(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_all_feedback_labels_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_all_feedback_labels._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_all_feedback_labels_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAllFeedbackLabelsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = contact_center_insights.ListAllFeedbackLabelsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_all_feedback_labels(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}:listAllFeedbackLabels" + % client.transport._host, + args[1], + ) + + +def test_list_all_feedback_labels_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_all_feedback_labels( + contact_center_insights.ListAllFeedbackLabelsRequest(), + parent="parent_value", + ) + + +def test_list_all_feedback_labels_rest_pager(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + next_page_token="abc", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[], + next_page_token="def", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + ], + next_page_token="ghi", + ), + contact_center_insights.ListAllFeedbackLabelsResponse( + feedback_labels=[ + resources.FeedbackLabel(), + resources.FeedbackLabel(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + contact_center_insights.ListAllFeedbackLabelsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_all_feedback_labels(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.FeedbackLabel) for i in results) + + pages = list(client.list_all_feedback_labels(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_bulk_upload_feedback_labels_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.bulk_upload_feedback_labels + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.bulk_upload_feedback_labels + ] = mock_rpc + + request = {} + client.bulk_upload_feedback_labels(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.bulk_upload_feedback_labels(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_bulk_upload_feedback_labels_rest_required_fields( + request_type=contact_center_insights.BulkUploadFeedbackLabelsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_upload_feedback_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_upload_feedback_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.bulk_upload_feedback_labels(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_bulk_upload_feedback_labels_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.bulk_upload_feedback_labels._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_bulk_upload_feedback_labels_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.bulk_upload_feedback_labels(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}:bulkUploadFeedbackLabels" + % client.transport._host, + args[1], + ) + + +def test_bulk_upload_feedback_labels_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_upload_feedback_labels( + contact_center_insights.BulkUploadFeedbackLabelsRequest(), + parent="parent_value", + ) + + +def test_bulk_download_feedback_labels_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.bulk_download_feedback_labels + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.bulk_download_feedback_labels + ] = mock_rpc + + request = {} + client.bulk_download_feedback_labels(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.bulk_download_feedback_labels(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_bulk_download_feedback_labels_rest_required_fields( + request_type=contact_center_insights.BulkDownloadFeedbackLabelsRequest, +): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_download_feedback_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).bulk_download_feedback_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.bulk_download_feedback_labels(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_bulk_download_feedback_labels_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.bulk_download_feedback_labels._get_unset_required_fields( + {} + ) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +def test_bulk_download_feedback_labels_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.bulk_download_feedback_labels(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}:bulkDownloadFeedbackLabels" + % client.transport._host, + args[1], + ) + + +def test_bulk_download_feedback_labels_rest_flattened_error(transport: str = "rest"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_download_feedback_labels( + contact_center_insights.BulkDownloadFeedbackLabelsRequest(), + parent="parent_value", + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = ContactCenterInsightsClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ContactCenterInsightsGrpcTransport, + transports.ContactCenterInsightsGrpcAsyncIOTransport, + transports.ContactCenterInsightsRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_grpc(): + transport = ContactCenterInsightsClient.get_transport_class("grpc")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "grpc" + + +def test_initialize_client_w_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_conversation_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), "__call__" + ) as call: + call.return_value = resources.Conversation() + client.create_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_upload_conversation_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.upload_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UploadConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_conversation_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), "__call__" + ) as call: + call.return_value = resources.Conversation() + client.update_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_conversation_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_conversation), "__call__") as call: + call.return_value = resources.Conversation() + client.get_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_conversations_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), "__call__" + ) as call: + call.return_value = contact_center_insights.ListConversationsResponse() + client.list_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_conversation_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), "__call__" + ) as call: + call.return_value = None + client.delete_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_analysis_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_analysis), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_analysis(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateAnalysisRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_analysis_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_analysis), "__call__") as call: + call.return_value = resources.Analysis() + client.get_analysis(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetAnalysisRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_analyses_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_analyses), "__call__") as call: + call.return_value = contact_center_insights.ListAnalysesResponse() + client.list_analyses(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListAnalysesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_analysis_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_analysis), "__call__") as call: + call.return_value = None + client.delete_analysis(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteAnalysisRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_bulk_analyze_conversations_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.bulk_analyze_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkAnalyzeConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_bulk_delete_conversations_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_delete_conversations), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.bulk_delete_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkDeleteConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_ingest_conversations_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.ingest_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.IngestConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_insights_data_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.export_insights_data(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ExportInsightsDataRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + call.return_value = resources.IssueModel() + client.update_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + call.return_value = resources.IssueModel() + client.get_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_issue_models_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + call.return_value = contact_center_insights.ListIssueModelsResponse() + client.list_issue_models(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListIssueModelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_deploy_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.deploy_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeployIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_undeploy_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.undeploy_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UndeployIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.export_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ExportIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_import_issue_model_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.import_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.import_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ImportIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_issue_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + call.return_value = resources.Issue() + client.get_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_issues_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + call.return_value = contact_center_insights.ListIssuesResponse() + client.list_issues(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListIssuesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_issue_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + call.return_value = resources.Issue() + client.update_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_issue_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + call.return_value = None + client.delete_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_calculate_issue_model_stats_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), "__call__" + ) as call: + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + client.calculate_issue_model_stats(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CalculateIssueModelStatsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_phrase_matcher_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), "__call__" + ) as call: + call.return_value = resources.PhraseMatcher() + client.create_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreatePhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_phrase_matcher_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), "__call__" + ) as call: + call.return_value = resources.PhraseMatcher() + client.get_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetPhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_phrase_matchers_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), "__call__" + ) as call: + call.return_value = contact_center_insights.ListPhraseMatchersResponse() + client.list_phrase_matchers(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListPhraseMatchersRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_phrase_matcher_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), "__call__" + ) as call: + call.return_value = None + client.delete_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeletePhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_phrase_matcher_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), "__call__" + ) as call: + call.return_value = resources.PhraseMatcher() + client.update_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdatePhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_calculate_stats_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.calculate_stats), "__call__") as call: + call.return_value = contact_center_insights.CalculateStatsResponse() + client.calculate_stats(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CalculateStatsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_settings_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_settings), "__call__") as call: + call.return_value = resources.Settings() + client.get_settings(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetSettingsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_settings_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_settings), "__call__") as call: + call.return_value = resources.Settings() + client.update_settings(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateSettingsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_analysis_rule_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis_rule), "__call__" + ) as call: + call.return_value = resources.AnalysisRule() + client.create_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_analysis_rule_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis_rule), "__call__" + ) as call: + call.return_value = resources.AnalysisRule() + client.get_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_analysis_rules_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: + call.return_value = contact_center_insights.ListAnalysisRulesResponse() + client.list_analysis_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListAnalysisRulesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_analysis_rule_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: + call.return_value = resources.AnalysisRule() + client.update_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_analysis_rule_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: + call.return_value = None + client.delete_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_encryption_spec_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: + call.return_value = resources.EncryptionSpec() + client.get_encryption_spec(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetEncryptionSpecRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_initialize_encryption_spec_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.initialize_encryption_spec(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.InitializeEncryptionSpecRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_view_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + call.return_value = resources.View() + client.create_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_view_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + call.return_value = resources.View() + client.get_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_views_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + call.return_value = contact_center_insights.ListViewsResponse() + client.list_views(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListViewsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_view_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + call.return_value = resources.View() + client.update_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_view_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + call.return_value = None + client.delete_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_query_metrics_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.query_metrics(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.QueryMetricsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_qa_question_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + call.return_value = resources.QaQuestion() + client.create_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_qa_question_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + call.return_value = resources.QaQuestion() + client.get_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_qa_question_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + call.return_value = resources.QaQuestion() + client.update_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_qa_question_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + call.return_value = None + client.delete_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_qa_questions_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + call.return_value = contact_center_insights.ListQaQuestionsResponse() + client.list_qa_questions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListQaQuestionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_qa_scorecard_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + call.return_value = resources.QaScorecard() + client.create_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_qa_scorecard_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + call.return_value = resources.QaScorecard() + client.get_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_qa_scorecard_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + call.return_value = resources.QaScorecard() + client.update_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_qa_scorecard_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + call.return_value = None + client.delete_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_qa_scorecards_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + call.return_value = contact_center_insights.ListQaScorecardsResponse() + client.list_qa_scorecards(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListQaScorecardsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_qa_scorecard_revision_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.create_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_qa_scorecard_revision_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.get_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_tune_qa_scorecard_revision_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.tune_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.TuneQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_deploy_qa_scorecard_revision_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.deploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.deploy_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeployQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_undeploy_qa_scorecard_revision_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = resources.QaScorecardRevision() + client.undeploy_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UndeployQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_qa_scorecard_revision_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + call.return_value = None + client.delete_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_qa_scorecard_revisions_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + call.return_value = contact_center_insights.ListQaScorecardRevisionsResponse() + client.list_qa_scorecard_revisions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListQaScorecardRevisionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_feedback_label_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + call.return_value = resources.FeedbackLabel() + client.create_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_feedback_labels_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + call.return_value = contact_center_insights.ListFeedbackLabelsResponse() + client.list_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListFeedbackLabelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_feedback_label_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + call.return_value = resources.FeedbackLabel() + client.get_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_feedback_label_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + call.return_value = resources.FeedbackLabel() + client.update_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_feedback_label_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + call.return_value = None + client.delete_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_all_feedback_labels_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + call.return_value = contact_center_insights.ListAllFeedbackLabelsResponse() + client.list_all_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListAllFeedbackLabelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_bulk_upload_feedback_labels_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_upload_feedback_labels), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.bulk_upload_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkUploadFeedbackLabelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_bulk_download_feedback_labels_empty_call_grpc(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_download_feedback_labels), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.bulk_download_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkDownloadFeedbackLabelsRequest() + + assert args[0] == request_msg + + +def test_transport_kind_grpc_asyncio(): + transport = ContactCenterInsightsAsyncClient.get_transport_class("grpc_asyncio")( + credentials=async_anonymous_credentials() + ) + assert transport.kind == "grpc_asyncio" + + +def test_initialize_client_w_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), transport="grpc_asyncio" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_conversation_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Conversation( + name="name_value", + language_code="language_code_value", + agent_id="agent_id_value", + metadata_json="metadata_json_value", + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id="obfuscated_user_id_value", + ) + ) + await client.create_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_upload_conversation_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.upload_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UploadConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_conversation_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Conversation( + name="name_value", + language_code="language_code_value", + agent_id="agent_id_value", + metadata_json="metadata_json_value", + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id="obfuscated_user_id_value", + ) + ) + await client.update_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_conversation_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_conversation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Conversation( + name="name_value", + language_code="language_code_value", + agent_id="agent_id_value", + metadata_json="metadata_json_value", + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id="obfuscated_user_id_value", + ) + ) + await client.get_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_conversations_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListConversationsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_conversation_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_analysis_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_analysis), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_analysis(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateAnalysisRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_analysis_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_analysis), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Analysis( + name="name_value", + ) + ) + await client.get_analysis(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetAnalysisRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_analyses_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_analyses), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAnalysesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_analyses(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListAnalysesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_analysis_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_analysis), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_analysis(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteAnalysisRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_bulk_analyze_conversations_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.bulk_analyze_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkAnalyzeConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_bulk_delete_conversations_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_delete_conversations), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.bulk_delete_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkDeleteConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_ingest_conversations_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.ingest_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.IngestConversationsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_export_insights_data_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.export_insights_data(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ExportInsightsDataRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel( + name="name_value", + display_name="display_name_value", + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code="language_code_value", + ) + ) + await client.update_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel( + name="name_value", + display_name="display_name_value", + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code="language_code_value", + ) + ) + await client.get_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_issue_models_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListIssueModelsResponse() + ) + await client.list_issue_models(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListIssueModelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_deploy_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.deploy_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeployIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_undeploy_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.undeploy_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UndeployIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_export_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.export_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ExportIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_import_issue_model_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.import_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.import_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ImportIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_issue_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Issue( + name="name_value", + display_name="display_name_value", + sample_utterances=["sample_utterances_value"], + display_description="display_description_value", + ) + ) + await client.get_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_issues_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListIssuesResponse() + ) + await client.list_issues(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListIssuesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_issue_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Issue( + name="name_value", + display_name="display_name_value", + sample_utterances=["sample_utterances_value"], + display_description="display_description_value", + ) + ) + await client.update_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_issue_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.CalculateIssueModelStatsResponse() + ) + await client.calculate_issue_model_stats(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CalculateIssueModelStatsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_phrase_matcher_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.PhraseMatcher( + name="name_value", + revision_id="revision_id_value", + version_tag="version_tag_value", + display_name="display_name_value", + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + ) + await client.create_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreatePhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_phrase_matcher_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.PhraseMatcher( + name="name_value", + revision_id="revision_id_value", + version_tag="version_tag_value", + display_name="display_name_value", + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + ) + await client.get_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetPhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_phrase_matchers_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListPhraseMatchersResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_phrase_matchers(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListPhraseMatchersRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_phrase_matcher_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeletePhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_phrase_matcher_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.PhraseMatcher( + name="name_value", + revision_id="revision_id_value", + version_tag="version_tag_value", + display_name="display_name_value", + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + ) + await client.update_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdatePhraseMatcherRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_calculate_stats_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.calculate_stats), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.CalculateStatsResponse( + average_turn_count=1931, + conversation_count=1955, + ) + ) + await client.calculate_stats(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CalculateStatsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_settings_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_settings), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Settings( + name="name_value", + language_code="language_code_value", + ) + ) + await client.get_settings(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetSettingsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_settings_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_settings), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Settings( + name="name_value", + language_code="language_code_value", + ) + ) + await client.update_settings(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateSettingsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_analysis_rule_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AnalysisRule( + name="name_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, + ) + ) + await client.create_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_analysis_rule_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AnalysisRule( + name="name_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, + ) + ) + await client.get_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_analysis_rules_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAnalysisRulesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_analysis_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListAnalysisRulesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_analysis_rule_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AnalysisRule( + name="name_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, + ) + ) + await client.update_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_analysis_rule_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_analysis_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteAnalysisRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_encryption_spec_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_encryption_spec), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.EncryptionSpec( + name="name_value", + kms_key="kms_key_value", + ) + ) + await client.get_encryption_spec(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetEncryptionSpecRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_initialize_encryption_spec_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.initialize_encryption_spec), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.initialize_encryption_spec(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.InitializeEncryptionSpecRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_view_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) + ) + await client.create_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_view_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) + ) + await client.get_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_views_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListViewsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_views(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListViewsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_view_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) + ) + await client.update_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_view_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_view(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteViewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_query_metrics_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.query_metrics(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.QueryMetricsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_qa_question_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) + ) + await client.create_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_qa_question_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) + ) + await client.get_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_qa_question_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) + ) + await client.update_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_qa_question_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_question), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_qa_question(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteQaQuestionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_qa_questions_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_questions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaQuestionsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_qa_questions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListQaQuestionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_qa_scorecard_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) + ) + await client.create_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_qa_scorecard_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) + ) + await client.get_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_qa_scorecard_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) + ) + await client.update_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_qa_scorecard_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_qa_scorecard(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteQaScorecardRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_qa_scorecards_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecards), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_qa_scorecards(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListQaScorecardsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_qa_scorecard_revision_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + ) + await client.create_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_qa_scorecard_revision_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + ) + await client.get_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_tune_qa_scorecard_revision_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.tune_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.tune_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.TuneQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_deploy_qa_scorecard_revision_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.deploy_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + ) + await client.deploy_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeployQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_undeploy_qa_scorecard_revision_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) + ) + await client.undeploy_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UndeployQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_qa_scorecard_revision_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_qa_scorecard_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteQaScorecardRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_qa_scorecard_revisions_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListQaScorecardRevisionsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_qa_scorecard_revisions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListQaScorecardRevisionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_feedback_label_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + ) + ) + await client.create_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_feedback_labels_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListFeedbackLabelsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListFeedbackLabelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_feedback_label_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + ) + ) + await client.get_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_feedback_label_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + ) + ) + await client.update_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_feedback_label_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_feedback_label(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteFeedbackLabelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_all_feedback_labels_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListAllFeedbackLabelsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_all_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListAllFeedbackLabelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_bulk_upload_feedback_labels_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_upload_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.bulk_upload_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkUploadFeedbackLabelsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_bulk_download_feedback_labels_empty_call_grpc_asyncio(): + client = ContactCenterInsightsAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_download_feedback_labels), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.bulk_download_feedback_labels(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkDownloadFeedbackLabelsRequest() + + assert args[0] == request_msg + + +def test_transport_kind_rest(): + transport = ContactCenterInsightsClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_create_conversation_rest_bad_request( + request_type=contact_center_insights.CreateConversationRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.create_conversation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateConversationRequest, + dict, + ], +) def test_create_conversation_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["conversation"] = { - "call_metadata": {"customer_channel": 1706, "agent_channel": 1351}, - "expire_time": {"seconds": 751, "nanos": 543}, - "ttl": {"seconds": 751, "nanos": 543}, - "name": "name_value", - "data_source": { - "gcs_source": { - "audio_uri": "audio_uri_value", - "transcript_uri": "transcript_uri_value", - }, - "dialogflow_source": { - "dialogflow_conversation": "dialogflow_conversation_value", - "audio_uri": "audio_uri_value", - }, - }, - "create_time": {}, + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["conversation"] = { + "call_metadata": {"customer_channel": 1706, "agent_channel": 1351}, + "expire_time": {"seconds": 751, "nanos": 543}, + "ttl": {"seconds": 751, "nanos": 543}, + "name": "name_value", + "data_source": { + "gcs_source": { + "audio_uri": "audio_uri_value", + "transcript_uri": "transcript_uri_value", + }, + "dialogflow_source": { + "dialogflow_conversation": "dialogflow_conversation_value", + "audio_uri": "audio_uri_value", + }, + }, + "create_time": {}, + "update_time": {}, + "start_time": {}, + "language_code": "language_code_value", + "agent_id": "agent_id_value", + "labels": {}, + "quality_metadata": { + "customer_satisfaction_rating": 3005, + "wait_duration": {}, + "menu_path": "menu_path_value", + "agent_info": [ + { + "agent_id": "agent_id_value", + "display_name": "display_name_value", + "team": "team_value", + "disposition_code": "disposition_code_value", + } + ], + }, + "metadata_json": "metadata_json_value", + "transcript": { + "transcript_segments": [ + { + "message_time": {}, + "text": "text_value", + "confidence": 0.1038, + "words": [ + { + "start_offset": {}, + "end_offset": {}, + "word": "word_value", + "confidence": 0.1038, + } + ], + "language_code": "language_code_value", + "channel_tag": 1140, + "segment_participant": { + "dialogflow_participant_name": "dialogflow_participant_name_value", + "user_id": "user_id_value", + "dialogflow_participant": "dialogflow_participant_value", + "obfuscated_external_user_id": "obfuscated_external_user_id_value", + "role": 1, + }, + "dialogflow_segment_metadata": { + "smart_reply_allowlist_covered": True + }, + "sentiment": {"magnitude": 0.9580000000000001, "score": 0.54}, + } + ] + }, + "medium": 1, + "duration": {}, + "turn_count": 1105, + "latest_analysis": { + "name": "name_value", + "request_time": {}, + "create_time": {}, + "analysis_result": { + "call_analysis_metadata": { + "annotations": [ + { + "interruption_data": {}, + "sentiment_data": {}, + "silence_data": {}, + "hold_data": {}, + "entity_mention_data": { + "entity_unique_id": "entity_unique_id_value", + "type_": 1, + "sentiment": {}, + }, + "intent_match_data": { + "intent_unique_id": "intent_unique_id_value" + }, + "phrase_match_data": { + "phrase_matcher": "phrase_matcher_value", + "display_name": "display_name_value", + }, + "issue_match_data": { + "issue_assignment": { + "issue": "issue_value", + "score": 0.54, + "display_name": "display_name_value", + } + }, + "channel_tag": 1140, + "annotation_start_boundary": { + "word_index": 1075, + "transcript_index": 1729, + }, + "annotation_end_boundary": {}, + } + ], + "entities": {}, + "sentiments": [{"channel_tag": 1140, "sentiment_data": {}}], + "silence": {"silence_duration": {}, "silence_percentage": 0.1888}, + "intents": {}, + "phrase_matchers": {}, + "issue_model_result": { + "issue_model": "issue_model_value", + "issues": {}, + }, + "qa_scorecard_results": [ + { + "name": "name_value", + "qa_scorecard_revision": "qa_scorecard_revision_value", + "conversation": "conversation_value", + "create_time": {}, + "agent_id": "agent_id_value", + "qa_answers": [ + { + "qa_question": "qa_question_value", + "conversation": "conversation_value", + "question_body": "question_body_value", + "answer_value": { + "str_value": "str_value_value", + "num_value": 0.972, + "bool_value": True, + "na_value": True, + "key": "key_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + }, + "tags": ["tags_value1", "tags_value2"], + "answer_sources": [ + {"source_type": 1, "answer_value": {}} + ], + } + ], + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + "qa_tag_results": [ + { + "tag": "tag_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + } + ], + "score_sources": [ + { + "source_type": 1, + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + "qa_tag_results": {}, + } + ], + } + ], + }, + "end_time": {}, + }, + "annotator_selector": { + "run_interruption_annotator": True, + "run_silence_annotator": True, + "run_phrase_matcher_annotator": True, + "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], + "run_sentiment_annotator": True, + "run_entity_annotator": True, + "run_intent_annotator": True, + "run_issue_model_annotator": True, + "issue_models": ["issue_models_value1", "issue_models_value2"], + "run_summarization_annotator": True, + "summarization_config": { + "conversation_profile": "conversation_profile_value", + "summarization_model": 1, + }, + "run_qa_annotator": True, + "qa_config": { + "scorecard_list": { + "qa_scorecard_revisions": [ + "qa_scorecard_revisions_value1", + "qa_scorecard_revisions_value2", + ] + } + }, + }, + }, + "latest_summary": { + "text": "text_value", + "text_sections": {}, + "confidence": 0.1038, + "metadata": {}, + "answer_record": "answer_record_value", + "conversation_model": "conversation_model_value", + }, + "runtime_annotations": [ + { + "article_suggestion": { + "title": "title_value", + "uri": "uri_value", + "confidence_score": 0.1673, + "metadata": {}, + "query_record": "query_record_value", + "source": "source_value", + }, + "faq_answer": { + "answer": "answer_value", + "confidence_score": 0.1673, + "question": "question_value", + "metadata": {}, + "query_record": "query_record_value", + "source": "source_value", + }, + "smart_reply": { + "reply": "reply_value", + "confidence_score": 0.1673, + "metadata": {}, + "query_record": "query_record_value", + }, + "smart_compose_suggestion": { + "suggestion": "suggestion_value", + "confidence_score": 0.1673, + "metadata": {}, + "query_record": "query_record_value", + }, + "dialogflow_interaction": { + "dialogflow_intent_id": "dialogflow_intent_id_value", + "confidence": 0.1038, + }, + "conversation_summarization_suggestion": {}, + "annotation_id": "annotation_id_value", + "create_time": {}, + "start_boundary": {}, + "end_boundary": {}, + "answer_feedback": { + "correctness_level": 1, + "clicked": True, + "displayed": True, + }, + "user_input": { + "query": "query_value", + "generator_name": "generator_name_value", + "query_source": 1, + }, + } + ], + "dialogflow_intents": {}, + "obfuscated_user_id": "obfuscated_user_id_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.CreateConversationRequest.meta.fields[ + "conversation" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["conversation"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["conversation"][field])): + del request_init["conversation"][field][i][subfield] + else: + del request_init["conversation"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation( + name="name_value", + language_code="language_code_value", + agent_id="agent_id_value", + metadata_json="metadata_json_value", + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id="obfuscated_user_id_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_conversation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == "name_value" + assert response.language_code == "language_code_value" + assert response.agent_id == "agent_id_value" + assert response.metadata_json == "metadata_json_value" + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == "obfuscated_user_id_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_create_conversation" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_create_conversation" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreateConversationRequest.pb( + contact_center_insights.CreateConversationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Conversation.to_json(resources.Conversation()) + req.return_value.content = return_value + + request = contact_center_insights.CreateConversationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Conversation() + + client.create_conversation( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_upload_conversation_rest_bad_request( + request_type=contact_center_insights.UploadConversationRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.upload_conversation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UploadConversationRequest, + dict, + ], +) +def test_upload_conversation_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.upload_conversation(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_upload_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_upload_conversation" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_upload_conversation" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UploadConversationRequest.pb( + contact_center_insights.UploadConversationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.UploadConversationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.upload_conversation( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_conversation_rest_bad_request( + request_type=contact_center_insights.UpdateConversationRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "conversation": { + "name": "projects/sample1/locations/sample2/conversations/sample3" + } + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.update_conversation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateConversationRequest, + dict, + ], +) +def test_update_conversation_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "conversation": { + "name": "projects/sample1/locations/sample2/conversations/sample3" + } + } + request_init["conversation"] = { + "call_metadata": {"customer_channel": 1706, "agent_channel": 1351}, + "expire_time": {"seconds": 751, "nanos": 543}, + "ttl": {"seconds": 751, "nanos": 543}, + "name": "projects/sample1/locations/sample2/conversations/sample3", + "data_source": { + "gcs_source": { + "audio_uri": "audio_uri_value", + "transcript_uri": "transcript_uri_value", + }, + "dialogflow_source": { + "dialogflow_conversation": "dialogflow_conversation_value", + "audio_uri": "audio_uri_value", + }, + }, + "create_time": {}, + "update_time": {}, + "start_time": {}, + "language_code": "language_code_value", + "agent_id": "agent_id_value", + "labels": {}, + "quality_metadata": { + "customer_satisfaction_rating": 3005, + "wait_duration": {}, + "menu_path": "menu_path_value", + "agent_info": [ + { + "agent_id": "agent_id_value", + "display_name": "display_name_value", + "team": "team_value", + "disposition_code": "disposition_code_value", + } + ], + }, + "metadata_json": "metadata_json_value", + "transcript": { + "transcript_segments": [ + { + "message_time": {}, + "text": "text_value", + "confidence": 0.1038, + "words": [ + { + "start_offset": {}, + "end_offset": {}, + "word": "word_value", + "confidence": 0.1038, + } + ], + "language_code": "language_code_value", + "channel_tag": 1140, + "segment_participant": { + "dialogflow_participant_name": "dialogflow_participant_name_value", + "user_id": "user_id_value", + "dialogflow_participant": "dialogflow_participant_value", + "obfuscated_external_user_id": "obfuscated_external_user_id_value", + "role": 1, + }, + "dialogflow_segment_metadata": { + "smart_reply_allowlist_covered": True + }, + "sentiment": {"magnitude": 0.9580000000000001, "score": 0.54}, + } + ] + }, + "medium": 1, + "duration": {}, + "turn_count": 1105, + "latest_analysis": { + "name": "name_value", + "request_time": {}, + "create_time": {}, + "analysis_result": { + "call_analysis_metadata": { + "annotations": [ + { + "interruption_data": {}, + "sentiment_data": {}, + "silence_data": {}, + "hold_data": {}, + "entity_mention_data": { + "entity_unique_id": "entity_unique_id_value", + "type_": 1, + "sentiment": {}, + }, + "intent_match_data": { + "intent_unique_id": "intent_unique_id_value" + }, + "phrase_match_data": { + "phrase_matcher": "phrase_matcher_value", + "display_name": "display_name_value", + }, + "issue_match_data": { + "issue_assignment": { + "issue": "issue_value", + "score": 0.54, + "display_name": "display_name_value", + } + }, + "channel_tag": 1140, + "annotation_start_boundary": { + "word_index": 1075, + "transcript_index": 1729, + }, + "annotation_end_boundary": {}, + } + ], + "entities": {}, + "sentiments": [{"channel_tag": 1140, "sentiment_data": {}}], + "silence": {"silence_duration": {}, "silence_percentage": 0.1888}, + "intents": {}, + "phrase_matchers": {}, + "issue_model_result": { + "issue_model": "issue_model_value", + "issues": {}, + }, + "qa_scorecard_results": [ + { + "name": "name_value", + "qa_scorecard_revision": "qa_scorecard_revision_value", + "conversation": "conversation_value", + "create_time": {}, + "agent_id": "agent_id_value", + "qa_answers": [ + { + "qa_question": "qa_question_value", + "conversation": "conversation_value", + "question_body": "question_body_value", + "answer_value": { + "str_value": "str_value_value", + "num_value": 0.972, + "bool_value": True, + "na_value": True, + "key": "key_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + }, + "tags": ["tags_value1", "tags_value2"], + "answer_sources": [ + {"source_type": 1, "answer_value": {}} + ], + } + ], + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + "qa_tag_results": [ + { + "tag": "tag_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + } + ], + "score_sources": [ + { + "source_type": 1, + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + "qa_tag_results": {}, + } + ], + } + ], + }, + "end_time": {}, + }, + "annotator_selector": { + "run_interruption_annotator": True, + "run_silence_annotator": True, + "run_phrase_matcher_annotator": True, + "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], + "run_sentiment_annotator": True, + "run_entity_annotator": True, + "run_intent_annotator": True, + "run_issue_model_annotator": True, + "issue_models": ["issue_models_value1", "issue_models_value2"], + "run_summarization_annotator": True, + "summarization_config": { + "conversation_profile": "conversation_profile_value", + "summarization_model": 1, + }, + "run_qa_annotator": True, + "qa_config": { + "scorecard_list": { + "qa_scorecard_revisions": [ + "qa_scorecard_revisions_value1", + "qa_scorecard_revisions_value2", + ] + } + }, + }, + }, + "latest_summary": { + "text": "text_value", + "text_sections": {}, + "confidence": 0.1038, + "metadata": {}, + "answer_record": "answer_record_value", + "conversation_model": "conversation_model_value", + }, + "runtime_annotations": [ + { + "article_suggestion": { + "title": "title_value", + "uri": "uri_value", + "confidence_score": 0.1673, + "metadata": {}, + "query_record": "query_record_value", + "source": "source_value", + }, + "faq_answer": { + "answer": "answer_value", + "confidence_score": 0.1673, + "question": "question_value", + "metadata": {}, + "query_record": "query_record_value", + "source": "source_value", + }, + "smart_reply": { + "reply": "reply_value", + "confidence_score": 0.1673, + "metadata": {}, + "query_record": "query_record_value", + }, + "smart_compose_suggestion": { + "suggestion": "suggestion_value", + "confidence_score": 0.1673, + "metadata": {}, + "query_record": "query_record_value", + }, + "dialogflow_interaction": { + "dialogflow_intent_id": "dialogflow_intent_id_value", + "confidence": 0.1038, + }, + "conversation_summarization_suggestion": {}, + "annotation_id": "annotation_id_value", + "create_time": {}, + "start_boundary": {}, + "end_boundary": {}, + "answer_feedback": { + "correctness_level": 1, + "clicked": True, + "displayed": True, + }, + "user_input": { + "query": "query_value", + "generator_name": "generator_name_value", + "query_source": 1, + }, + } + ], + "dialogflow_intents": {}, + "obfuscated_user_id": "obfuscated_user_id_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.UpdateConversationRequest.meta.fields[ + "conversation" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["conversation"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["conversation"][field])): + del request_init["conversation"][field][i][subfield] + else: + del request_init["conversation"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation( + name="name_value", + language_code="language_code_value", + agent_id="agent_id_value", + metadata_json="metadata_json_value", + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id="obfuscated_user_id_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_conversation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == "name_value" + assert response.language_code == "language_code_value" + assert response.agent_id == "agent_id_value" + assert response.metadata_json == "metadata_json_value" + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == "obfuscated_user_id_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_update_conversation" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_update_conversation" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateConversationRequest.pb( + contact_center_insights.UpdateConversationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Conversation.to_json(resources.Conversation()) + req.return_value.content = return_value + + request = contact_center_insights.UpdateConversationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Conversation() + + client.update_conversation( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_conversation_rest_bad_request( + request_type=contact_center_insights.GetConversationRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_conversation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetConversationRequest, + dict, + ], +) +def test_get_conversation_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation( + name="name_value", + language_code="language_code_value", + agent_id="agent_id_value", + metadata_json="metadata_json_value", + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id="obfuscated_user_id_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_conversation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == "name_value" + assert response.language_code == "language_code_value" + assert response.agent_id == "agent_id_value" + assert response.metadata_json == "metadata_json_value" + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == "obfuscated_user_id_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_get_conversation" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_get_conversation" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetConversationRequest.pb( + contact_center_insights.GetConversationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Conversation.to_json(resources.Conversation()) + req.return_value.content = return_value + + request = contact_center_insights.GetConversationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Conversation() + + client.get_conversation( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_conversations_rest_bad_request( + request_type=contact_center_insights.ListConversationsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_conversations(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListConversationsRequest, + dict, + ], +) +def test_list_conversations_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListConversationsResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListConversationsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_conversations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversationsPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_conversations_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_list_conversations" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_list_conversations" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListConversationsRequest.pb( + contact_center_insights.ListConversationsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = contact_center_insights.ListConversationsResponse.to_json( + contact_center_insights.ListConversationsResponse() + ) + req.return_value.content = return_value + + request = contact_center_insights.ListConversationsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListConversationsResponse() + + client.list_conversations( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_conversation_rest_bad_request( + request_type=contact_center_insights.DeleteConversationRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.delete_conversation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteConversationRequest, + dict, + ], +) +def test_delete_conversation_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "" + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_conversation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_delete_conversation" + ) as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteConversationRequest.pb( + contact_center_insights.DeleteConversationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + + request = contact_center_insights.DeleteConversationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_conversation( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_create_analysis_rest_bad_request( + request_type=contact_center_insights.CreateAnalysisRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.create_analysis(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateAnalysisRequest, + dict, + ], +) +def test_create_analysis_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + request_init["analysis"] = { + "name": "name_value", + "request_time": {"seconds": 751, "nanos": 543}, + "create_time": {}, + "analysis_result": { + "call_analysis_metadata": { + "annotations": [ + { + "interruption_data": {}, + "sentiment_data": { + "magnitude": 0.9580000000000001, + "score": 0.54, + }, + "silence_data": {}, + "hold_data": {}, + "entity_mention_data": { + "entity_unique_id": "entity_unique_id_value", + "type_": 1, + "sentiment": {}, + }, + "intent_match_data": { + "intent_unique_id": "intent_unique_id_value" + }, + "phrase_match_data": { + "phrase_matcher": "phrase_matcher_value", + "display_name": "display_name_value", + }, + "issue_match_data": { + "issue_assignment": { + "issue": "issue_value", + "score": 0.54, + "display_name": "display_name_value", + } + }, + "channel_tag": 1140, + "annotation_start_boundary": { + "word_index": 1075, + "transcript_index": 1729, + }, + "annotation_end_boundary": {}, + } + ], + "entities": {}, + "sentiments": [{"channel_tag": 1140, "sentiment_data": {}}], + "silence": { + "silence_duration": {"seconds": 751, "nanos": 543}, + "silence_percentage": 0.1888, + }, + "intents": {}, + "phrase_matchers": {}, + "issue_model_result": { + "issue_model": "issue_model_value", + "issues": {}, + }, + "qa_scorecard_results": [ + { + "name": "name_value", + "qa_scorecard_revision": "qa_scorecard_revision_value", + "conversation": "conversation_value", + "create_time": {}, + "agent_id": "agent_id_value", + "qa_answers": [ + { + "qa_question": "qa_question_value", + "conversation": "conversation_value", + "question_body": "question_body_value", + "answer_value": { + "str_value": "str_value_value", + "num_value": 0.972, + "bool_value": True, + "na_value": True, + "key": "key_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + }, + "tags": ["tags_value1", "tags_value2"], + "answer_sources": [ + {"source_type": 1, "answer_value": {}} + ], + } + ], + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + "qa_tag_results": [ + { + "tag": "tag_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + } + ], + "score_sources": [ + { + "source_type": 1, + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + "qa_tag_results": {}, + } + ], + } + ], + }, + "end_time": {}, + }, + "annotator_selector": { + "run_interruption_annotator": True, + "run_silence_annotator": True, + "run_phrase_matcher_annotator": True, + "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], + "run_sentiment_annotator": True, + "run_entity_annotator": True, + "run_intent_annotator": True, + "run_issue_model_annotator": True, + "issue_models": ["issue_models_value1", "issue_models_value2"], + "run_summarization_annotator": True, + "summarization_config": { + "conversation_profile": "conversation_profile_value", + "summarization_model": 1, + }, + "run_qa_annotator": True, + "qa_config": { + "scorecard_list": { + "qa_scorecard_revisions": [ + "qa_scorecard_revisions_value1", + "qa_scorecard_revisions_value2", + ] + } + }, + }, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.CreateAnalysisRequest.meta.fields["analysis"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["analysis"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["analysis"][field])): + del request_init["analysis"][field][i][subfield] + else: + del request_init["analysis"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_analysis(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_analysis_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_create_analysis" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_create_analysis" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreateAnalysisRequest.pb( + contact_center_insights.CreateAnalysisRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.CreateAnalysisRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_analysis( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_analysis_rest_bad_request( + request_type=contact_center_insights.GetAnalysisRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_analysis(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetAnalysisRequest, + dict, + ], +) +def test_get_analysis_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Analysis( + name="name_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Analysis.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_analysis(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Analysis) + assert response.name == "name_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_analysis_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_get_analysis" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_get_analysis" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetAnalysisRequest.pb( + contact_center_insights.GetAnalysisRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Analysis.to_json(resources.Analysis()) + req.return_value.content = return_value + + request = contact_center_insights.GetAnalysisRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Analysis() + + client.get_analysis( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_analyses_rest_bad_request( + request_type=contact_center_insights.ListAnalysesRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_analyses(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListAnalysesRequest, + dict, + ], +) +def test_list_analyses_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_analyses(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAnalysesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_analyses_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_list_analyses" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_list_analyses" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListAnalysesRequest.pb( + contact_center_insights.ListAnalysesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = contact_center_insights.ListAnalysesResponse.to_json( + contact_center_insights.ListAnalysesResponse() + ) + req.return_value.content = return_value + + request = contact_center_insights.ListAnalysesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListAnalysesResponse() + + client.list_analyses( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_analysis_rest_bad_request( + request_type=contact_center_insights.DeleteAnalysisRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.delete_analysis(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteAnalysisRequest, + dict, + ], +) +def test_delete_analysis_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "" + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_analysis(request) + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_analysis_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_delete_analysis" + ) as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteAnalysisRequest.pb( + contact_center_insights.DeleteAnalysisRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + + request = contact_center_insights.DeleteAnalysisRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_analysis( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_bulk_analyze_conversations_rest_bad_request( + request_type=contact_center_insights.BulkAnalyzeConversationsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.bulk_analyze_conversations(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.BulkAnalyzeConversationsRequest, + dict, + ], +) +def test_bulk_analyze_conversations_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.bulk_analyze_conversations(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_bulk_analyze_conversations_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "post_bulk_analyze_conversations", + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "pre_bulk_analyze_conversations", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.BulkAnalyzeConversationsRequest.pb( + contact_center_insights.BulkAnalyzeConversationsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.BulkAnalyzeConversationsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.bulk_analyze_conversations( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_bulk_delete_conversations_rest_bad_request( + request_type=contact_center_insights.BulkDeleteConversationsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.bulk_delete_conversations(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.BulkDeleteConversationsRequest, + dict, + ], +) +def test_bulk_delete_conversations_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.bulk_delete_conversations(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_bulk_delete_conversations_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "post_bulk_delete_conversations", + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_bulk_delete_conversations" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.BulkDeleteConversationsRequest.pb( + contact_center_insights.BulkDeleteConversationsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.BulkDeleteConversationsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.bulk_delete_conversations( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_ingest_conversations_rest_bad_request( + request_type=contact_center_insights.IngestConversationsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.ingest_conversations(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.IngestConversationsRequest, + dict, + ], +) +def test_ingest_conversations_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.ingest_conversations(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_ingest_conversations_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_ingest_conversations" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_ingest_conversations" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.IngestConversationsRequest.pb( + contact_center_insights.IngestConversationsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.IngestConversationsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.ingest_conversations( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_export_insights_data_rest_bad_request( + request_type=contact_center_insights.ExportInsightsDataRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.export_insights_data(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ExportInsightsDataRequest, + dict, + ], +) +def test_export_insights_data_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.export_insights_data(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_export_insights_data_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_export_insights_data" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_export_insights_data" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ExportInsightsDataRequest.pb( + contact_center_insights.ExportInsightsDataRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.ExportInsightsDataRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.export_insights_data( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_issue_model_rest_bad_request( + request_type=contact_center_insights.CreateIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.create_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateIssueModelRequest, + dict, + ], +) +def test_create_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["issue_model"] = { + "name": "name_value", + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "issue_count": 1201, + "state": 1, + "input_data_config": { + "medium": 1, + "training_conversations_count": 3025, + "filter": "filter_value", + }, + "training_stats": { + "analyzed_conversations_count": 3021, + "unclassified_conversations_count": 3439, + "issue_stats": {}, + }, + "model_type": 1, + "language_code": "language_code_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.CreateIssueModelRequest.meta.fields[ + "issue_model" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["issue_model"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["issue_model"][field])): + del request_init["issue_model"][field][i][subfield] + else: + del request_init["issue_model"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_issue_model(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_create_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_create_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreateIssueModelRequest.pb( + contact_center_insights.CreateIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.CreateIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_issue_model_rest_bad_request( + request_type=contact_center_insights.UpdateIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "issue_model": { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.update_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateIssueModelRequest, + dict, + ], +) +def test_update_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "issue_model": { + "name": "projects/sample1/locations/sample2/issueModels/sample3" + } + } + request_init["issue_model"] = { + "name": "projects/sample1/locations/sample2/issueModels/sample3", + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "issue_count": 1201, + "state": 1, + "input_data_config": { + "medium": 1, + "training_conversations_count": 3025, + "filter": "filter_value", + }, + "training_stats": { + "analyzed_conversations_count": 3021, + "unclassified_conversations_count": 3439, + "issue_stats": {}, + }, + "model_type": 1, + "language_code": "language_code_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.UpdateIssueModelRequest.meta.fields[ + "issue_model" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["issue_model"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["issue_model"][field])): + del request_init["issue_model"][field][i][subfield] + else: + del request_init["issue_model"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel( + name="name_value", + display_name="display_name_value", + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code="language_code_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_issue_model(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == "language_code_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_update_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_update_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateIssueModelRequest.pb( + contact_center_insights.UpdateIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.IssueModel.to_json(resources.IssueModel()) + req.return_value.content = return_value + + request = contact_center_insights.UpdateIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.IssueModel() + + client.update_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_issue_model_rest_bad_request( + request_type=contact_center_insights.GetIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetIssueModelRequest, + dict, + ], +) +def test_get_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel( + name="name_value", + display_name="display_name_value", + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code="language_code_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_issue_model(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == "language_code_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_get_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_get_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetIssueModelRequest.pb( + contact_center_insights.GetIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.IssueModel.to_json(resources.IssueModel()) + req.return_value.content = return_value + + request = contact_center_insights.GetIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.IssueModel() + + client.get_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_issue_models_rest_bad_request( + request_type=contact_center_insights.ListIssueModelsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_issue_models(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListIssueModelsRequest, + dict, + ], +) +def test_list_issue_models_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssueModelsResponse() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_issue_models(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_issue_models_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_list_issue_models" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_list_issue_models" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListIssueModelsRequest.pb( + contact_center_insights.ListIssueModelsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = contact_center_insights.ListIssueModelsResponse.to_json( + contact_center_insights.ListIssueModelsResponse() + ) + req.return_value.content = return_value + + request = contact_center_insights.ListIssueModelsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListIssueModelsResponse() + + client.list_issue_models( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_issue_model_rest_bad_request( + request_type=contact_center_insights.DeleteIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.delete_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteIssueModelRequest, + dict, + ], +) +def test_delete_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_issue_model(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_delete_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.DeleteIssueModelRequest.pb( + contact_center_insights.DeleteIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.DeleteIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_deploy_issue_model_rest_bad_request( + request_type=contact_center_insights.DeployIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.deploy_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeployIssueModelRequest, + dict, + ], +) +def test_deploy_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.deploy_issue_model(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_deploy_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_deploy_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_deploy_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.DeployIssueModelRequest.pb( + contact_center_insights.DeployIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.DeployIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.deploy_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_undeploy_issue_model_rest_bad_request( + request_type=contact_center_insights.UndeployIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.undeploy_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UndeployIssueModelRequest, + dict, + ], +) +def test_undeploy_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.undeploy_issue_model(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_undeploy_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_undeploy_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_undeploy_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UndeployIssueModelRequest.pb( + contact_center_insights.UndeployIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.UndeployIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.undeploy_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_export_issue_model_rest_bad_request( + request_type=contact_center_insights.ExportIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.export_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ExportIssueModelRequest, + dict, + ], +) +def test_export_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.export_issue_model(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_export_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_export_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_export_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ExportIssueModelRequest.pb( + contact_center_insights.ExportIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.ExportIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.export_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_import_issue_model_rest_bad_request( + request_type=contact_center_insights.ImportIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.import_issue_model(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ImportIssueModelRequest, + dict, + ], +) +def test_import_issue_model_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.import_issue_model(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_import_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_import_issue_model" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_import_issue_model" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ImportIssueModelRequest.pb( + contact_center_insights.ImportIssueModelRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = contact_center_insights.ImportIssueModelRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.import_issue_model( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_issue_rest_bad_request( + request_type=contact_center_insights.GetIssueRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_issue(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetIssueRequest, + dict, + ], +) +def test_get_issue_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue( + name="name_value", + display_name="display_name_value", + sample_utterances=["sample_utterances_value"], + display_description="display_description_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_issue(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.sample_utterances == ["sample_utterances_value"] + assert response.display_description == "display_description_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_issue_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_get_issue" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_get_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetIssueRequest.pb( + contact_center_insights.GetIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Issue.to_json(resources.Issue()) + req.return_value.content = return_value + + request = contact_center_insights.GetIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Issue() + + client.get_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_issues_rest_bad_request( + request_type=contact_center_insights.ListIssuesRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_issues(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListIssuesRequest, + dict, + ], +) +def test_list_issues_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/issueModels/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssuesResponse() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_issues(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssuesResponse) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_issues_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_list_issues" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_list_issues" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListIssuesRequest.pb( + contact_center_insights.ListIssuesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = contact_center_insights.ListIssuesResponse.to_json( + contact_center_insights.ListIssuesResponse() + ) + req.return_value.content = return_value + + request = contact_center_insights.ListIssuesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListIssuesResponse() + + client.list_issues( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_issue_rest_bad_request( + request_type=contact_center_insights.UpdateIssueRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "issue": { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.update_issue(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateIssueRequest, + dict, + ], +) +def test_update_issue_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "issue": { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + } + request_init["issue"] = { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4", + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "sample_utterances": ["sample_utterances_value1", "sample_utterances_value2"], + "display_description": "display_description_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.UpdateIssueRequest.meta.fields["issue"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["issue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["issue"][field])): + del request_init["issue"][field][i][subfield] + else: + del request_init["issue"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue( + name="name_value", + display_name="display_name_value", + sample_utterances=["sample_utterances_value"], + display_description="display_description_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_issue(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.sample_utterances == ["sample_utterances_value"] + assert response.display_description == "display_description_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_issue_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_update_issue" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_update_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateIssueRequest.pb( + contact_center_insights.UpdateIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Issue.to_json(resources.Issue()) + req.return_value.content = return_value + + request = contact_center_insights.UpdateIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Issue() + + client.update_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_issue_rest_bad_request( + request_type=contact_center_insights.DeleteIssueRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.delete_issue(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeleteIssueRequest, + dict, + ], +) +def test_delete_issue_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "" + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_issue(request) + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_issue_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue" + ) as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteIssueRequest.pb( + contact_center_insights.DeleteIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + + request = contact_center_insights.DeleteIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_calculate_issue_model_stats_rest_bad_request( + request_type=contact_center_insights.CalculateIssueModelStatsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "issue_model": "projects/sample1/locations/sample2/issueModels/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.calculate_issue_model_stats(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CalculateIssueModelStatsRequest, + dict, + ], +) +def test_calculate_issue_model_stats_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "issue_model": "projects/sample1/locations/sample2/issueModels/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateIssueModelStatsResponse() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.calculate_issue_model_stats(request) + + # Establish that the response is the type that we expect. + assert isinstance( + response, contact_center_insights.CalculateIssueModelStatsResponse + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_calculate_issue_model_stats_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "post_calculate_issue_model_stats", + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "pre_calculate_issue_model_stats", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CalculateIssueModelStatsRequest.pb( + contact_center_insights.CalculateIssueModelStatsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = contact_center_insights.CalculateIssueModelStatsResponse.to_json( + contact_center_insights.CalculateIssueModelStatsResponse() + ) + req.return_value.content = return_value + + request = contact_center_insights.CalculateIssueModelStatsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + + client.calculate_issue_model_stats( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_phrase_matcher_rest_bad_request( + request_type=contact_center_insights.CreatePhraseMatcherRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.create_phrase_matcher(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreatePhraseMatcherRequest, + dict, + ], +) +def test_create_phrase_matcher_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["phrase_matcher"] = { + "name": "name_value", + "revision_id": "revision_id_value", + "version_tag": "version_tag_value", + "revision_create_time": {"seconds": 751, "nanos": 543}, + "display_name": "display_name_value", + "type_": 1, + "active": True, + "phrase_match_rule_groups": [ + { + "type_": 1, + "phrase_match_rules": [ + { + "query": "query_value", + "negated": True, + "config": {"exact_match_config": {"case_sensitive": True}}, + } + ], + } + ], + "activation_update_time": {}, + "role_match": 1, + "update_time": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.CreatePhraseMatcherRequest.meta.fields[ + "phrase_matcher" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["phrase_matcher"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["phrase_matcher"][field])): + del request_init["phrase_matcher"][field][i][subfield] + else: + del request_init["phrase_matcher"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher( + name="name_value", + revision_id="revision_id_value", + version_tag="version_tag_value", + display_name="display_name_value", + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == "name_value" + assert response.revision_id == "revision_id_value" + assert response.version_tag == "version_tag_value" + assert response.display_name == "display_name_value" + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_create_phrase_matcher" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_create_phrase_matcher" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreatePhraseMatcherRequest.pb( + contact_center_insights.CreatePhraseMatcherRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + req.return_value.content = return_value + + request = contact_center_insights.CreatePhraseMatcherRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.PhraseMatcher() + + client.create_phrase_matcher( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_phrase_matcher_rest_bad_request( + request_type=contact_center_insights.GetPhraseMatcherRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_phrase_matcher(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetPhraseMatcherRequest, + dict, + ], +) +def test_get_phrase_matcher_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher( + name="name_value", + revision_id="revision_id_value", + version_tag="version_tag_value", + display_name="display_name_value", + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == "name_value" + assert response.revision_id == "revision_id_value" + assert response.version_tag == "version_tag_value" + assert response.display_name == "display_name_value" + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_get_phrase_matcher" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_get_phrase_matcher" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetPhraseMatcherRequest.pb( + contact_center_insights.GetPhraseMatcherRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + req.return_value.content = return_value + + request = contact_center_insights.GetPhraseMatcherRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.PhraseMatcher() + + client.get_phrase_matcher( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_phrase_matchers_rest_bad_request( + request_type=contact_center_insights.ListPhraseMatchersRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_phrase_matchers(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListPhraseMatchersRequest, + dict, + ], +) +def test_list_phrase_matchers_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListPhraseMatchersResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListPhraseMatchersResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_phrase_matchers(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPhraseMatchersPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_phrase_matchers_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_list_phrase_matchers" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_list_phrase_matchers" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListPhraseMatchersRequest.pb( + contact_center_insights.ListPhraseMatchersRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = contact_center_insights.ListPhraseMatchersResponse.to_json( + contact_center_insights.ListPhraseMatchersResponse() + ) + req.return_value.content = return_value + + request = contact_center_insights.ListPhraseMatchersRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListPhraseMatchersResponse() + + client.list_phrase_matchers( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_phrase_matcher_rest_bad_request( + request_type=contact_center_insights.DeletePhraseMatcherRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.delete_phrase_matcher(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.DeletePhraseMatcherRequest, + dict, + ], +) +def test_delete_phrase_matcher_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "" + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_delete_phrase_matcher" + ) as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeletePhraseMatcherRequest.pb( + contact_center_insights.DeletePhraseMatcherRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + + request = contact_center_insights.DeletePhraseMatcherRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_phrase_matcher( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_update_phrase_matcher_rest_bad_request( + request_type=contact_center_insights.UpdatePhraseMatcherRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "phrase_matcher": { + "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" + } + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.update_phrase_matcher(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdatePhraseMatcherRequest, + dict, + ], +) +def test_update_phrase_matcher_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "phrase_matcher": { + "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" + } + } + request_init["phrase_matcher"] = { + "name": "projects/sample1/locations/sample2/phraseMatchers/sample3", + "revision_id": "revision_id_value", + "version_tag": "version_tag_value", + "revision_create_time": {"seconds": 751, "nanos": 543}, + "display_name": "display_name_value", + "type_": 1, + "active": True, + "phrase_match_rule_groups": [ + { + "type_": 1, + "phrase_match_rules": [ + { + "query": "query_value", + "negated": True, + "config": {"exact_match_config": {"case_sensitive": True}}, + } + ], + } + ], + "activation_update_time": {}, + "role_match": 1, + "update_time": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.UpdatePhraseMatcherRequest.meta.fields[ + "phrase_matcher" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["phrase_matcher"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["phrase_matcher"][field])): + del request_init["phrase_matcher"][field][i][subfield] + else: + del request_init["phrase_matcher"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher( + name="name_value", + revision_id="revision_id_value", + version_tag="version_tag_value", + display_name="display_name_value", + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == "name_value" + assert response.revision_id == "revision_id_value" + assert response.version_tag == "version_tag_value" + assert response.display_name == "display_name_value" + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_update_phrase_matcher" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_update_phrase_matcher" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdatePhraseMatcherRequest.pb( + contact_center_insights.UpdatePhraseMatcherRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + req.return_value.content = return_value + + request = contact_center_insights.UpdatePhraseMatcherRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.PhraseMatcher() + + client.update_phrase_matcher( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_calculate_stats_rest_bad_request( + request_type=contact_center_insights.CalculateStatsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"location": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.calculate_stats(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CalculateStatsRequest, + dict, + ], +) +def test_calculate_stats_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"location": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateStatsResponse( + average_turn_count=1931, + conversation_count=1955, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.calculate_stats(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateStatsResponse) + assert response.average_turn_count == 1931 + assert response.conversation_count == 1955 + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_calculate_stats_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_calculate_stats" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_calculate_stats" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CalculateStatsRequest.pb( + contact_center_insights.CalculateStatsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = contact_center_insights.CalculateStatsResponse.to_json( + contact_center_insights.CalculateStatsResponse() + ) + req.return_value.content = return_value + + request = contact_center_insights.CalculateStatsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.CalculateStatsResponse() + + client.calculate_stats( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_settings_rest_bad_request( + request_type=contact_center_insights.GetSettingsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/settings"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_settings(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetSettingsRequest, + dict, + ], +) +def test_get_settings_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/settings"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings( + name="name_value", + language_code="language_code_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_settings(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == "name_value" + assert response.language_code == "language_code_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_settings_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_get_settings" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_get_settings" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetSettingsRequest.pb( + contact_center_insights.GetSettingsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Settings.to_json(resources.Settings()) + req.return_value.content = return_value + + request = contact_center_insights.GetSettingsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Settings() + + client.get_settings( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_settings_rest_bad_request( + request_type=contact_center_insights.UpdateSettingsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"settings": {"name": "projects/sample1/locations/sample2/settings"}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.update_settings(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.UpdateSettingsRequest, + dict, + ], +) +def test_update_settings_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"settings": {"name": "projects/sample1/locations/sample2/settings"}} + request_init["settings"] = { + "name": "projects/sample1/locations/sample2/settings", + "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, - "start_time": {}, "language_code": "language_code_value", - "agent_id": "agent_id_value", - "labels": {}, - "quality_metadata": { - "customer_satisfaction_rating": 3005, - "wait_duration": {}, - "menu_path": "menu_path_value", - "agent_info": [ - { - "agent_id": "agent_id_value", - "display_name": "display_name_value", - "team": "team_value", - "disposition_code": "disposition_code_value", - } - ], - }, - "metadata_json": "metadata_json_value", - "transcript": { - "transcript_segments": [ - { - "message_time": {}, - "text": "text_value", - "confidence": 0.1038, - "words": [ - { - "start_offset": {}, - "end_offset": {}, - "word": "word_value", - "confidence": 0.1038, - } - ], - "language_code": "language_code_value", - "channel_tag": 1140, - "segment_participant": { - "dialogflow_participant_name": "dialogflow_participant_name_value", - "user_id": "user_id_value", - "dialogflow_participant": "dialogflow_participant_value", - "obfuscated_external_user_id": "obfuscated_external_user_id_value", - "role": 1, - }, - "dialogflow_segment_metadata": { - "smart_reply_allowlist_covered": True - }, - "sentiment": {"magnitude": 0.9580000000000001, "score": 0.54}, - } - ] - }, - "medium": 1, - "duration": {}, - "turn_count": 1105, - "latest_analysis": { - "name": "name_value", - "request_time": {}, - "create_time": {}, - "analysis_result": { - "call_analysis_metadata": { - "annotations": [ - { - "interruption_data": {}, - "sentiment_data": {}, - "silence_data": {}, - "hold_data": {}, - "entity_mention_data": { - "entity_unique_id": "entity_unique_id_value", - "type_": 1, - "sentiment": {}, - }, - "intent_match_data": { - "intent_unique_id": "intent_unique_id_value" - }, - "phrase_match_data": { - "phrase_matcher": "phrase_matcher_value", - "display_name": "display_name_value", - }, - "issue_match_data": { - "issue_assignment": { - "issue": "issue_value", - "score": 0.54, - "display_name": "display_name_value", - } - }, - "channel_tag": 1140, - "annotation_start_boundary": { - "word_index": 1075, - "transcript_index": 1729, - }, - "annotation_end_boundary": {}, - } - ], - "entities": {}, - "sentiments": [{"channel_tag": 1140, "sentiment_data": {}}], - "silence": {"silence_duration": {}, "silence_percentage": 0.1888}, - "intents": {}, - "phrase_matchers": {}, - "issue_model_result": { - "issue_model": "issue_model_value", - "issues": {}, - }, - }, - "end_time": {}, - }, + "conversation_ttl": {"seconds": 751, "nanos": 543}, + "pubsub_notification_settings": {}, + "analysis_config": { + "runtime_integration_analysis_percentage": 0.4167, + "upload_conversation_analysis_percentage": 0.41590000000000005, "annotator_selector": { "run_interruption_annotator": True, "run_silence_annotator": True, @@ -27163,77 +52112,252 @@ def test_create_conversation_rest_call_success(request_type): "conversation_profile": "conversation_profile_value", "summarization_model": 1, }, + "run_qa_annotator": True, + "qa_config": { + "scorecard_list": { + "qa_scorecard_revisions": [ + "qa_scorecard_revisions_value1", + "qa_scorecard_revisions_value2", + ] + } + }, + }, + }, + "redaction_config": { + "deidentify_template": "deidentify_template_value", + "inspect_template": "inspect_template_value", + }, + "speech_config": {"speech_recognizer": "speech_recognizer_value"}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.UpdateSettingsRequest.meta.fields["settings"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["settings"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["settings"][field])): + del request_init["settings"][field][i][subfield] + else: + del request_init["settings"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings( + name="name_value", + language_code="language_code_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_settings(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == "name_value" + assert response.language_code == "language_code_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_settings_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_update_settings" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_update_settings" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateSettingsRequest.pb( + contact_center_insights.UpdateSettingsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.Settings.to_json(resources.Settings()) + req.return_value.content = return_value + + request = contact_center_insights.UpdateSettingsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Settings() + + client.update_settings( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_analysis_rule_rest_bad_request( + request_type=contact_center_insights.CreateAnalysisRuleRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.create_analysis_rule(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.CreateAnalysisRuleRequest, + dict, + ], +) +def test_create_analysis_rule_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["analysis_rule"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "display_name": "display_name_value", + "conversation_filter": "conversation_filter_value", + "annotator_selector": { + "run_interruption_annotator": True, + "run_silence_annotator": True, + "run_phrase_matcher_annotator": True, + "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], + "run_sentiment_annotator": True, + "run_entity_annotator": True, + "run_intent_annotator": True, + "run_issue_model_annotator": True, + "issue_models": ["issue_models_value1", "issue_models_value2"], + "run_summarization_annotator": True, + "summarization_config": { + "conversation_profile": "conversation_profile_value", + "summarization_model": 1, + }, + "run_qa_annotator": True, + "qa_config": { + "scorecard_list": { + "qa_scorecard_revisions": [ + "qa_scorecard_revisions_value1", + "qa_scorecard_revisions_value2", + ] + } }, }, - "latest_summary": { - "text": "text_value", - "text_sections": {}, - "confidence": 0.1038, - "metadata": {}, - "answer_record": "answer_record_value", - "conversation_model": "conversation_model_value", - }, - "runtime_annotations": [ - { - "article_suggestion": { - "title": "title_value", - "uri": "uri_value", - "confidence_score": 0.1673, - "metadata": {}, - "query_record": "query_record_value", - "source": "source_value", - }, - "faq_answer": { - "answer": "answer_value", - "confidence_score": 0.1673, - "question": "question_value", - "metadata": {}, - "query_record": "query_record_value", - "source": "source_value", - }, - "smart_reply": { - "reply": "reply_value", - "confidence_score": 0.1673, - "metadata": {}, - "query_record": "query_record_value", - }, - "smart_compose_suggestion": { - "suggestion": "suggestion_value", - "confidence_score": 0.1673, - "metadata": {}, - "query_record": "query_record_value", - }, - "dialogflow_interaction": { - "dialogflow_intent_id": "dialogflow_intent_id_value", - "confidence": 0.1038, - }, - "conversation_summarization_suggestion": {}, - "annotation_id": "annotation_id_value", - "create_time": {}, - "start_boundary": {}, - "end_boundary": {}, - "answer_feedback": { - "correctness_level": 1, - "clicked": True, - "displayed": True, - }, - "user_input": { - "query": "query_value", - "generator_name": "generator_name_value", - "query_source": 1, - }, - } - ], - "dialogflow_intents": {}, - "obfuscated_user_id": "obfuscated_user_id_value", + "analysis_percentage": 0.20170000000000002, + "active": True, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.CreateConversationRequest.meta.fields[ - "conversation" + test_field = contact_center_insights.CreateAnalysisRuleRequest.meta.fields[ + "analysis_rule" ] def get_message_fields(field): @@ -27262,7 +52386,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["conversation"].items(): # pragma: NO COVER + for field, value in request_init["analysis_rule"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -27292,23 +52416,21 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["conversation"][field])): - del request_init["conversation"][field][i][subfield] + for i in range(0, len(request_init["analysis_rule"][field])): + del request_init["analysis_rule"][field][i][subfield] else: - del request_init["conversation"][field][subfield] + del request_init["analysis_rule"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Conversation( + return_value = resources.AnalysisRule( name="name_value", - language_code="language_code_value", - agent_id="agent_id_value", - metadata_json="metadata_json_value", - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id="obfuscated_user_id_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, ) # Wrap the value into a proper Response obj @@ -27316,25 +52438,23 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) + return_value = resources.AnalysisRule.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_conversation(request) + response = client.create_analysis_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) + assert isinstance(response, resources.AnalysisRule) assert response.name == "name_value" - assert response.language_code == "language_code_value" - assert response.agent_id == "agent_id_value" - assert response.metadata_json == "metadata_json_value" - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == "obfuscated_user_id_value" + assert response.display_name == "display_name_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_conversation_rest_interceptors(null_interceptor): +def test_create_analysis_rule_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27348,14 +52468,14 @@ def test_create_conversation_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_create_conversation" + transports.ContactCenterInsightsRestInterceptor, "post_create_analysis_rule" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_create_conversation" + transports.ContactCenterInsightsRestInterceptor, "pre_create_analysis_rule" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.CreateConversationRequest.pb( - contact_center_insights.CreateConversationRequest() + pb_message = contact_center_insights.CreateAnalysisRuleRequest.pb( + contact_center_insights.CreateAnalysisRuleRequest() ) transcode.return_value = { "method": "post", @@ -27366,18 +52486,18 @@ def test_create_conversation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Conversation.to_json(resources.Conversation()) + return_value = resources.AnalysisRule.to_json(resources.AnalysisRule()) req.return_value.content = return_value - request = contact_center_insights.CreateConversationRequest() + request = contact_center_insights.CreateAnalysisRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Conversation() + post.return_value = resources.AnalysisRule() - client.create_conversation( + client.create_analysis_rule( request, metadata=[ ("key", "val"), @@ -27389,8 +52509,135 @@ def test_create_conversation_rest_interceptors(null_interceptor): post.assert_called_once() -def test_upload_conversation_rest_bad_request( - request_type=contact_center_insights.UploadConversationRequest, +def test_get_analysis_rule_rest_bad_request( + request_type=contact_center_insights.GetAnalysisRuleRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/analysisRules/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_analysis_rule(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.GetAnalysisRuleRequest, + dict, + ], +) +def test_get_analysis_rule_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/analysisRules/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.AnalysisRule( + name="name_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.AnalysisRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_analysis_rule(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AnalysisRule) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_analysis_rule_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "post_get_analysis_rule" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_get_analysis_rule" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetAnalysisRuleRequest.pb( + contact_center_insights.GetAnalysisRuleRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = resources.AnalysisRule.to_json(resources.AnalysisRule()) + req.return_value.content = return_value + + request = contact_center_insights.GetAnalysisRuleRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.AnalysisRule() + + client.get_analysis_rule( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_analysis_rules_rest_bad_request( + request_type=contact_center_insights.ListAnalysisRulesRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -27410,17 +52657,17 @@ def test_upload_conversation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.upload_conversation(request) + client.list_analysis_rules(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UploadConversationRequest, + contact_center_insights.ListAnalysisRulesRequest, dict, ], ) -def test_upload_conversation_rest_call_success(request_type): +def test_list_analysis_rules_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -27432,22 +52679,30 @@ def test_upload_conversation_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = contact_center_insights.ListAnalysisRulesResponse( + next_page_token="next_page_token_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListAnalysisRulesResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.upload_conversation(request) + response = client.list_analysis_rules(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, pagers.ListAnalysisRulesPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_upload_conversation_rest_interceptors(null_interceptor): +def test_list_analysis_rules_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27461,16 +52716,14 @@ def test_upload_conversation_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_upload_conversation" + transports.ContactCenterInsightsRestInterceptor, "post_list_analysis_rules" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_upload_conversation" + transports.ContactCenterInsightsRestInterceptor, "pre_list_analysis_rules" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.UploadConversationRequest.pb( - contact_center_insights.UploadConversationRequest() + pb_message = contact_center_insights.ListAnalysisRulesRequest.pb( + contact_center_insights.ListAnalysisRulesRequest() ) transcode.return_value = { "method": "post", @@ -27481,18 +52734,20 @@ def test_upload_conversation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = contact_center_insights.ListAnalysisRulesResponse.to_json( + contact_center_insights.ListAnalysisRulesResponse() + ) req.return_value.content = return_value - request = contact_center_insights.UploadConversationRequest() + request = contact_center_insights.ListAnalysisRulesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = contact_center_insights.ListAnalysisRulesResponse() - client.upload_conversation( + client.list_analysis_rules( request, metadata=[ ("key", "val"), @@ -27504,16 +52759,16 @@ def test_upload_conversation_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_conversation_rest_bad_request( - request_type=contact_center_insights.UpdateConversationRequest, +def test_update_analysis_rule_rest_bad_request( + request_type=contact_center_insights.UpdateAnalysisRuleRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "conversation": { - "name": "projects/sample1/locations/sample2/conversations/sample3" + "analysis_rule": { + "name": "projects/sample1/locations/sample2/analysisRules/sample3" } } request = request_type(**request_init) @@ -27529,232 +52784,68 @@ def test_update_conversation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_conversation(request) + client.update_analysis_rule(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UpdateConversationRequest, + contact_center_insights.UpdateAnalysisRuleRequest, dict, ], ) -def test_update_conversation_rest_call_success(request_type): +def test_update_analysis_rule_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "conversation": { - "name": "projects/sample1/locations/sample2/conversations/sample3" + "analysis_rule": { + "name": "projects/sample1/locations/sample2/analysisRules/sample3" } } - request_init["conversation"] = { - "call_metadata": {"customer_channel": 1706, "agent_channel": 1351}, - "expire_time": {"seconds": 751, "nanos": 543}, - "ttl": {"seconds": 751, "nanos": 543}, - "name": "projects/sample1/locations/sample2/conversations/sample3", - "data_source": { - "gcs_source": { - "audio_uri": "audio_uri_value", - "transcript_uri": "transcript_uri_value", - }, - "dialogflow_source": { - "dialogflow_conversation": "dialogflow_conversation_value", - "audio_uri": "audio_uri_value", - }, - }, - "create_time": {}, + request_init["analysis_rule"] = { + "name": "projects/sample1/locations/sample2/analysisRules/sample3", + "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, - "start_time": {}, - "language_code": "language_code_value", - "agent_id": "agent_id_value", - "labels": {}, - "quality_metadata": { - "customer_satisfaction_rating": 3005, - "wait_duration": {}, - "menu_path": "menu_path_value", - "agent_info": [ - { - "agent_id": "agent_id_value", - "display_name": "display_name_value", - "team": "team_value", - "disposition_code": "disposition_code_value", - } - ], - }, - "metadata_json": "metadata_json_value", - "transcript": { - "transcript_segments": [ - { - "message_time": {}, - "text": "text_value", - "confidence": 0.1038, - "words": [ - { - "start_offset": {}, - "end_offset": {}, - "word": "word_value", - "confidence": 0.1038, - } - ], - "language_code": "language_code_value", - "channel_tag": 1140, - "segment_participant": { - "dialogflow_participant_name": "dialogflow_participant_name_value", - "user_id": "user_id_value", - "dialogflow_participant": "dialogflow_participant_value", - "obfuscated_external_user_id": "obfuscated_external_user_id_value", - "role": 1, - }, - "dialogflow_segment_metadata": { - "smart_reply_allowlist_covered": True - }, - "sentiment": {"magnitude": 0.9580000000000001, "score": 0.54}, - } - ] - }, - "medium": 1, - "duration": {}, - "turn_count": 1105, - "latest_analysis": { - "name": "name_value", - "request_time": {}, - "create_time": {}, - "analysis_result": { - "call_analysis_metadata": { - "annotations": [ - { - "interruption_data": {}, - "sentiment_data": {}, - "silence_data": {}, - "hold_data": {}, - "entity_mention_data": { - "entity_unique_id": "entity_unique_id_value", - "type_": 1, - "sentiment": {}, - }, - "intent_match_data": { - "intent_unique_id": "intent_unique_id_value" - }, - "phrase_match_data": { - "phrase_matcher": "phrase_matcher_value", - "display_name": "display_name_value", - }, - "issue_match_data": { - "issue_assignment": { - "issue": "issue_value", - "score": 0.54, - "display_name": "display_name_value", - } - }, - "channel_tag": 1140, - "annotation_start_boundary": { - "word_index": 1075, - "transcript_index": 1729, - }, - "annotation_end_boundary": {}, - } - ], - "entities": {}, - "sentiments": [{"channel_tag": 1140, "sentiment_data": {}}], - "silence": {"silence_duration": {}, "silence_percentage": 0.1888}, - "intents": {}, - "phrase_matchers": {}, - "issue_model_result": { - "issue_model": "issue_model_value", - "issues": {}, - }, - }, - "end_time": {}, + "display_name": "display_name_value", + "conversation_filter": "conversation_filter_value", + "annotator_selector": { + "run_interruption_annotator": True, + "run_silence_annotator": True, + "run_phrase_matcher_annotator": True, + "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], + "run_sentiment_annotator": True, + "run_entity_annotator": True, + "run_intent_annotator": True, + "run_issue_model_annotator": True, + "issue_models": ["issue_models_value1", "issue_models_value2"], + "run_summarization_annotator": True, + "summarization_config": { + "conversation_profile": "conversation_profile_value", + "summarization_model": 1, }, - "annotator_selector": { - "run_interruption_annotator": True, - "run_silence_annotator": True, - "run_phrase_matcher_annotator": True, - "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], - "run_sentiment_annotator": True, - "run_entity_annotator": True, - "run_intent_annotator": True, - "run_issue_model_annotator": True, - "issue_models": ["issue_models_value1", "issue_models_value2"], - "run_summarization_annotator": True, - "summarization_config": { - "conversation_profile": "conversation_profile_value", - "summarization_model": 1, - }, + "run_qa_annotator": True, + "qa_config": { + "scorecard_list": { + "qa_scorecard_revisions": [ + "qa_scorecard_revisions_value1", + "qa_scorecard_revisions_value2", + ] + } }, }, - "latest_summary": { - "text": "text_value", - "text_sections": {}, - "confidence": 0.1038, - "metadata": {}, - "answer_record": "answer_record_value", - "conversation_model": "conversation_model_value", - }, - "runtime_annotations": [ - { - "article_suggestion": { - "title": "title_value", - "uri": "uri_value", - "confidence_score": 0.1673, - "metadata": {}, - "query_record": "query_record_value", - "source": "source_value", - }, - "faq_answer": { - "answer": "answer_value", - "confidence_score": 0.1673, - "question": "question_value", - "metadata": {}, - "query_record": "query_record_value", - "source": "source_value", - }, - "smart_reply": { - "reply": "reply_value", - "confidence_score": 0.1673, - "metadata": {}, - "query_record": "query_record_value", - }, - "smart_compose_suggestion": { - "suggestion": "suggestion_value", - "confidence_score": 0.1673, - "metadata": {}, - "query_record": "query_record_value", - }, - "dialogflow_interaction": { - "dialogflow_intent_id": "dialogflow_intent_id_value", - "confidence": 0.1038, - }, - "conversation_summarization_suggestion": {}, - "annotation_id": "annotation_id_value", - "create_time": {}, - "start_boundary": {}, - "end_boundary": {}, - "answer_feedback": { - "correctness_level": 1, - "clicked": True, - "displayed": True, - }, - "user_input": { - "query": "query_value", - "generator_name": "generator_name_value", - "query_source": 1, - }, - } - ], - "dialogflow_intents": {}, - "obfuscated_user_id": "obfuscated_user_id_value", + "analysis_percentage": 0.20170000000000002, + "active": True, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.UpdateConversationRequest.meta.fields[ - "conversation" + test_field = contact_center_insights.UpdateAnalysisRuleRequest.meta.fields[ + "analysis_rule" ] def get_message_fields(field): @@ -27783,7 +52874,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["conversation"].items(): # pragma: NO COVER + for field, value in request_init["analysis_rule"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -27813,23 +52904,21 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["conversation"][field])): - del request_init["conversation"][field][i][subfield] + for i in range(0, len(request_init["analysis_rule"][field])): + del request_init["analysis_rule"][field][i][subfield] else: - del request_init["conversation"][field][subfield] + del request_init["analysis_rule"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Conversation( + return_value = resources.AnalysisRule( name="name_value", - language_code="language_code_value", - agent_id="agent_id_value", - metadata_json="metadata_json_value", - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id="obfuscated_user_id_value", + display_name="display_name_value", + conversation_filter="conversation_filter_value", + analysis_percentage=0.20170000000000002, + active=True, ) # Wrap the value into a proper Response obj @@ -27837,25 +52926,23 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) + return_value = resources.AnalysisRule.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_conversation(request) + response = client.update_analysis_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) + assert isinstance(response, resources.AnalysisRule) assert response.name == "name_value" - assert response.language_code == "language_code_value" - assert response.agent_id == "agent_id_value" - assert response.metadata_json == "metadata_json_value" - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == "obfuscated_user_id_value" + assert response.display_name == "display_name_value" + assert response.conversation_filter == "conversation_filter_value" + assert math.isclose(response.analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + assert response.active is True @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_conversation_rest_interceptors(null_interceptor): +def test_update_analysis_rule_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27869,14 +52956,14 @@ def test_update_conversation_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_update_conversation" + transports.ContactCenterInsightsRestInterceptor, "post_update_analysis_rule" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_update_conversation" + transports.ContactCenterInsightsRestInterceptor, "pre_update_analysis_rule" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.UpdateConversationRequest.pb( - contact_center_insights.UpdateConversationRequest() + pb_message = contact_center_insights.UpdateAnalysisRuleRequest.pb( + contact_center_insights.UpdateAnalysisRuleRequest() ) transcode.return_value = { "method": "post", @@ -27887,18 +52974,18 @@ def test_update_conversation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Conversation.to_json(resources.Conversation()) + return_value = resources.AnalysisRule.to_json(resources.AnalysisRule()) req.return_value.content = return_value - request = contact_center_insights.UpdateConversationRequest() + request = contact_center_insights.UpdateAnalysisRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Conversation() + post.return_value = resources.AnalysisRule() - client.update_conversation( + client.update_analysis_rule( request, metadata=[ ("key", "val"), @@ -27910,14 +52997,14 @@ def test_update_conversation_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_conversation_rest_bad_request( - request_type=contact_center_insights.GetConversationRequest, +def test_delete_analysis_rule_rest_bad_request( + request_type=contact_center_insights.DeleteAnalysisRuleRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/analysisRules/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27931,62 +53018,44 @@ def test_get_conversation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_conversation(request) + client.delete_analysis_rule(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetConversationRequest, + contact_center_insights.DeleteAnalysisRuleRequest, dict, ], ) -def test_get_conversation_rest_call_success(request_type): +def test_delete_analysis_rule_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation( - name="name_value", - language_code="language_code_value", - agent_id="agent_id_value", - metadata_json="metadata_json_value", - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id="obfuscated_user_id_value", - ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/analysisRules/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_conversation(request) + response = client.delete_analysis_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == "name_value" - assert response.language_code == "language_code_value" - assert response.agent_id == "agent_id_value" - assert response.metadata_json == "metadata_json_value" - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == "obfuscated_user_id_value" + assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_conversation_rest_interceptors(null_interceptor): +def test_delete_analysis_rule_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28000,14 +53069,11 @@ def test_get_conversation_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_conversation" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_conversation" + transports.ContactCenterInsightsRestInterceptor, "pre_delete_analysis_rule" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetConversationRequest.pb( - contact_center_insights.GetConversationRequest() + pb_message = contact_center_insights.DeleteAnalysisRuleRequest.pb( + contact_center_insights.DeleteAnalysisRuleRequest() ) transcode.return_value = { "method": "post", @@ -28018,18 +53084,15 @@ def test_get_conversation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Conversation.to_json(resources.Conversation()) - req.return_value.content = return_value - request = contact_center_insights.GetConversationRequest() + request = contact_center_insights.DeleteAnalysisRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Conversation() - client.get_conversation( + client.delete_analysis_rule( request, metadata=[ ("key", "val"), @@ -28038,17 +53101,16 @@ def test_get_conversation_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_list_conversations_rest_bad_request( - request_type=contact_center_insights.ListConversationsRequest, +def test_get_encryption_spec_rest_bad_request( + request_type=contact_center_insights.GetEncryptionSpecRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/encryptionSpec"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28062,30 +53124,31 @@ def test_list_conversations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_conversations(request) + client.get_encryption_spec(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ListConversationsRequest, + contact_center_insights.GetEncryptionSpecRequest, dict, ], ) -def test_list_conversations_rest_call_success(request_type): +def test_get_encryption_spec_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/encryptionSpec"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListConversationsResponse( - next_page_token="next_page_token_value", + return_value = resources.EncryptionSpec( + name="name_value", + kms_key="kms_key_value", ) # Wrap the value into a proper Response obj @@ -28093,21 +53156,20 @@ def test_list_conversations_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = contact_center_insights.ListConversationsResponse.pb( - return_value - ) + return_value = resources.EncryptionSpec.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_conversations(request) + response = client.get_encryption_spec(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConversationsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.EncryptionSpec) + assert response.name == "name_value" + assert response.kms_key == "kms_key_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_conversations_rest_interceptors(null_interceptor): +def test_get_encryption_spec_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28121,14 +53183,14 @@ def test_list_conversations_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_list_conversations" + transports.ContactCenterInsightsRestInterceptor, "post_get_encryption_spec" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_list_conversations" + transports.ContactCenterInsightsRestInterceptor, "pre_get_encryption_spec" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ListConversationsRequest.pb( - contact_center_insights.ListConversationsRequest() + pb_message = contact_center_insights.GetEncryptionSpecRequest.pb( + contact_center_insights.GetEncryptionSpecRequest() ) transcode.return_value = { "method": "post", @@ -28139,20 +53201,18 @@ def test_list_conversations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = contact_center_insights.ListConversationsResponse.to_json( - contact_center_insights.ListConversationsResponse() - ) + return_value = resources.EncryptionSpec.to_json(resources.EncryptionSpec()) req.return_value.content = return_value - request = contact_center_insights.ListConversationsRequest() + request = contact_center_insights.GetEncryptionSpecRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = contact_center_insights.ListConversationsResponse() + post.return_value = resources.EncryptionSpec() - client.list_conversations( + client.get_encryption_spec( request, metadata=[ ("key", "val"), @@ -28164,14 +53224,16 @@ def test_list_conversations_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_conversation_rest_bad_request( - request_type=contact_center_insights.DeleteConversationRequest, +def test_initialize_encryption_spec_rest_bad_request( + request_type=contact_center_insights.InitializeEncryptionSpecRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} + request_init = { + "encryption_spec": {"name": "projects/sample1/locations/sample2/encryptionSpec"} + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28185,44 +53247,46 @@ def test_delete_conversation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_conversation(request) + client.initialize_encryption_spec(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.DeleteConversationRequest, + contact_center_insights.InitializeEncryptionSpecRequest, dict, ], ) -def test_delete_conversation_rest_call_success(request_type): +def test_initialize_encryption_spec_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/conversations/sample3"} + request_init = { + "encryption_spec": {"name": "projects/sample1/locations/sample2/encryptionSpec"} + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = "" + json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_conversation(request) + response = client.initialize_encryption_spec(request) # Establish that the response is the type that we expect. - assert response is None + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_conversation_rest_interceptors(null_interceptor): +def test_initialize_encryption_spec_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28236,11 +53300,18 @@ def test_delete_conversation_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_delete_conversation" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "post_initialize_encryption_spec", + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "pre_initialize_encryption_spec", ) as pre: pre.assert_not_called() - pb_message = contact_center_insights.DeleteConversationRequest.pb( - contact_center_insights.DeleteConversationRequest() + post.assert_not_called() + pb_message = contact_center_insights.InitializeEncryptionSpecRequest.pb( + contact_center_insights.InitializeEncryptionSpecRequest() ) transcode.return_value = { "method": "post", @@ -28251,15 +53322,18 @@ def test_delete_conversation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - request = contact_center_insights.DeleteConversationRequest() + request = contact_center_insights.InitializeEncryptionSpecRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() - client.delete_conversation( + client.initialize_encryption_spec( request, metadata=[ ("key", "val"), @@ -28268,18 +53342,17 @@ def test_delete_conversation_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_create_analysis_rest_bad_request( - request_type=contact_center_insights.CreateAnalysisRequest, +def test_create_view_rest_bad_request( + request_type=contact_center_insights.CreateViewRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/conversations/sample3" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28293,105 +53366,36 @@ def test_create_analysis_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.create_analysis(request) + client.create_view(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.CreateAnalysisRequest, + contact_center_insights.CreateViewRequest, dict, ], ) -def test_create_analysis_rest_call_success(request_type): +def test_create_view_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/conversations/sample3" - } - request_init["analysis"] = { + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["view"] = { "name": "name_value", - "request_time": {"seconds": 751, "nanos": 543}, - "create_time": {}, - "analysis_result": { - "call_analysis_metadata": { - "annotations": [ - { - "interruption_data": {}, - "sentiment_data": { - "magnitude": 0.9580000000000001, - "score": 0.54, - }, - "silence_data": {}, - "hold_data": {}, - "entity_mention_data": { - "entity_unique_id": "entity_unique_id_value", - "type_": 1, - "sentiment": {}, - }, - "intent_match_data": { - "intent_unique_id": "intent_unique_id_value" - }, - "phrase_match_data": { - "phrase_matcher": "phrase_matcher_value", - "display_name": "display_name_value", - }, - "issue_match_data": { - "issue_assignment": { - "issue": "issue_value", - "score": 0.54, - "display_name": "display_name_value", - } - }, - "channel_tag": 1140, - "annotation_start_boundary": { - "word_index": 1075, - "transcript_index": 1729, - }, - "annotation_end_boundary": {}, - } - ], - "entities": {}, - "sentiments": [{"channel_tag": 1140, "sentiment_data": {}}], - "silence": { - "silence_duration": {"seconds": 751, "nanos": 543}, - "silence_percentage": 0.1888, - }, - "intents": {}, - "phrase_matchers": {}, - "issue_model_result": { - "issue_model": "issue_model_value", - "issues": {}, - }, - }, - "end_time": {}, - }, - "annotator_selector": { - "run_interruption_annotator": True, - "run_silence_annotator": True, - "run_phrase_matcher_annotator": True, - "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], - "run_sentiment_annotator": True, - "run_entity_annotator": True, - "run_intent_annotator": True, - "run_issue_model_annotator": True, - "issue_models": ["issue_models_value1", "issue_models_value2"], - "run_summarization_annotator": True, - "summarization_config": { - "conversation_profile": "conversation_profile_value", - "summarization_model": 1, - }, - }, + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "value": "value_value", } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.CreateAnalysisRequest.meta.fields["analysis"] + test_field = contact_center_insights.CreateViewRequest.meta.fields["view"] def get_message_fields(field): # Given a field which is a message (composite type), return a list with @@ -28419,7 +53423,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["analysis"].items(): # pragma: NO COVER + for field, value in request_init["view"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -28449,31 +53453,41 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["analysis"][field])): - del request_init["analysis"][field][i][subfield] + for i in range(0, len(request_init["view"][field])): + del request_init["view"][field][i][subfield] else: - del request_init["analysis"][field][subfield] + del request_init["view"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_analysis(request) + response = client.create_view(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_analysis_rest_interceptors(null_interceptor): +def test_create_view_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28487,16 +53501,14 @@ def test_create_analysis_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_create_analysis" + transports.ContactCenterInsightsRestInterceptor, "post_create_view" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_create_analysis" + transports.ContactCenterInsightsRestInterceptor, "pre_create_view" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.CreateAnalysisRequest.pb( - contact_center_insights.CreateAnalysisRequest() + pb_message = contact_center_insights.CreateViewRequest.pb( + contact_center_insights.CreateViewRequest() ) transcode.return_value = { "method": "post", @@ -28507,18 +53519,18 @@ def test_create_analysis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = resources.View.to_json(resources.View()) req.return_value.content = return_value - request = contact_center_insights.CreateAnalysisRequest() + request = contact_center_insights.CreateViewRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = resources.View() - client.create_analysis( + client.create_view( request, metadata=[ ("key", "val"), @@ -28530,16 +53542,12 @@ def test_create_analysis_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_analysis_rest_bad_request( - request_type=contact_center_insights.GetAnalysisRequest, -): +def test_get_view_rest_bad_request(request_type=contact_center_insights.GetViewRequest): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" - } + request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28553,32 +53561,32 @@ def test_get_analysis_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_analysis(request) + client.get_view(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetAnalysisRequest, + contact_center_insights.GetViewRequest, dict, ], ) -def test_get_analysis_rest_call_success(request_type): +def test_get_view_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" - } + request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Analysis( + return_value = resources.View( name="name_value", + display_name="display_name_value", + value="value_value", ) # Wrap the value into a proper Response obj @@ -28586,19 +53594,21 @@ def test_get_analysis_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.Analysis.pb(return_value) + return_value = resources.View.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_analysis(request) + response = client.get_view(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Analysis) + assert isinstance(response, resources.View) assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_analysis_rest_interceptors(null_interceptor): +def test_get_view_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28612,14 +53622,14 @@ def test_get_analysis_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_analysis" + transports.ContactCenterInsightsRestInterceptor, "post_get_view" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_analysis" + transports.ContactCenterInsightsRestInterceptor, "pre_get_view" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.GetAnalysisRequest.pb( - contact_center_insights.GetAnalysisRequest() + pb_message = contact_center_insights.GetViewRequest.pb( + contact_center_insights.GetViewRequest() ) transcode.return_value = { "method": "post", @@ -28630,18 +53640,18 @@ def test_get_analysis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Analysis.to_json(resources.Analysis()) + return_value = resources.View.to_json(resources.View()) req.return_value.content = return_value - request = contact_center_insights.GetAnalysisRequest() + request = contact_center_insights.GetViewRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Analysis() + post.return_value = resources.View() - client.get_analysis( + client.get_view( request, metadata=[ ("key", "val"), @@ -28653,16 +53663,14 @@ def test_get_analysis_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_analyses_rest_bad_request( - request_type=contact_center_insights.ListAnalysesRequest, +def test_list_views_rest_bad_request( + request_type=contact_center_insights.ListViewsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/conversations/sample3" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28676,31 +53684,29 @@ def test_list_analyses_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_analyses(request) + client.list_views(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ListAnalysesRequest, + contact_center_insights.ListViewsRequest, dict, ], ) -def test_list_analyses_rest_call_success(request_type): +def test_list_views_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/conversations/sample3" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListAnalysesResponse( + return_value = contact_center_insights.ListViewsResponse( next_page_token="next_page_token_value", ) @@ -28709,19 +53715,19 @@ def test_list_analyses_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) + return_value = contact_center_insights.ListViewsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_analyses(request) + response = client.list_views(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAnalysesPager) + assert isinstance(response, pagers.ListViewsPager) assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_analyses_rest_interceptors(null_interceptor): +def test_list_views_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28735,14 +53741,14 @@ def test_list_analyses_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_list_analyses" + transports.ContactCenterInsightsRestInterceptor, "post_list_views" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_list_analyses" + transports.ContactCenterInsightsRestInterceptor, "pre_list_views" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ListAnalysesRequest.pb( - contact_center_insights.ListAnalysesRequest() + pb_message = contact_center_insights.ListViewsRequest.pb( + contact_center_insights.ListViewsRequest() ) transcode.return_value = { "method": "post", @@ -28753,20 +53759,20 @@ def test_list_analyses_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = contact_center_insights.ListAnalysesResponse.to_json( - contact_center_insights.ListAnalysesResponse() + return_value = contact_center_insights.ListViewsResponse.to_json( + contact_center_insights.ListViewsResponse() ) req.return_value.content = return_value - request = contact_center_insights.ListAnalysesRequest() + request = contact_center_insights.ListViewsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = contact_center_insights.ListAnalysesResponse() + post.return_value = contact_center_insights.ListViewsResponse() - client.list_analyses( + client.list_views( request, metadata=[ ("key", "val"), @@ -28778,15 +53784,15 @@ def test_list_analyses_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_analysis_rest_bad_request( - request_type=contact_center_insights.DeleteAnalysisRequest, +def test_update_view_rest_bad_request( + request_type=contact_center_insights.UpdateViewRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + "view": {"name": "projects/sample1/locations/sample2/views/sample3"} } request = request_type(**request_init) @@ -28801,46 +53807,130 @@ def test_delete_analysis_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_analysis(request) + client.update_view(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.DeleteAnalysisRequest, + contact_center_insights.UpdateViewRequest, dict, ], ) -def test_delete_analysis_rest_call_success(request_type): +def test_update_view_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/conversations/sample3/analyses/sample4" + "view": {"name": "projects/sample1/locations/sample2/views/sample3"} + } + request_init["view"] = { + "name": "projects/sample1/locations/sample2/views/sample3", + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "value": "value_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.UpdateViewRequest.meta.fields["view"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["view"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["view"][field])): + del request_init["view"][field][i][subfield] + else: + del request_init["view"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.View( + name="name_value", + display_name="display_name_value", + value="value_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = "" + + # Convert return value to protobuf type + return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_analysis(request) + response = client.update_view(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.View) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.value == "value_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_analysis_rest_interceptors(null_interceptor): +def test_update_view_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28854,11 +53944,14 @@ def test_delete_analysis_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_delete_analysis" + transports.ContactCenterInsightsRestInterceptor, "post_update_view" + ) as post, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_update_view" ) as pre: pre.assert_not_called() - pb_message = contact_center_insights.DeleteAnalysisRequest.pb( - contact_center_insights.DeleteAnalysisRequest() + post.assert_not_called() + pb_message = contact_center_insights.UpdateViewRequest.pb( + contact_center_insights.UpdateViewRequest() ) transcode.return_value = { "method": "post", @@ -28869,15 +53962,18 @@ def test_delete_analysis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + return_value = resources.View.to_json(resources.View()) + req.return_value.content = return_value - request = contact_center_insights.DeleteAnalysisRequest() + request = contact_center_insights.UpdateViewRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.View() - client.delete_analysis( + client.update_view( request, metadata=[ ("key", "val"), @@ -28886,16 +53982,17 @@ def test_delete_analysis_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_bulk_analyze_conversations_rest_bad_request( - request_type=contact_center_insights.BulkAnalyzeConversationsRequest, +def test_delete_view_rest_bad_request( + request_type=contact_center_insights.DeleteViewRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28909,44 +54006,44 @@ def test_bulk_analyze_conversations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.bulk_analyze_conversations(request) + client.delete_view(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.BulkAnalyzeConversationsRequest, + contact_center_insights.DeleteViewRequest, dict, ], ) -def test_bulk_analyze_conversations_rest_call_success(request_type): +def test_delete_view_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.bulk_analyze_conversations(request) + response = client.delete_view(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_bulk_analyze_conversations_rest_interceptors(null_interceptor): +def test_delete_view_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28960,18 +54057,11 @@ def test_bulk_analyze_conversations_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, - "post_bulk_analyze_conversations", - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, - "pre_bulk_analyze_conversations", + transports.ContactCenterInsightsRestInterceptor, "pre_delete_view" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.BulkAnalyzeConversationsRequest.pb( - contact_center_insights.BulkAnalyzeConversationsRequest() + pb_message = contact_center_insights.DeleteViewRequest.pb( + contact_center_insights.DeleteViewRequest() ) transcode.return_value = { "method": "post", @@ -28982,18 +54072,15 @@ def test_bulk_analyze_conversations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - request = contact_center_insights.BulkAnalyzeConversationsRequest() + request = contact_center_insights.DeleteViewRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - client.bulk_analyze_conversations( + client.delete_view( request, metadata=[ ("key", "val"), @@ -29002,17 +54089,16 @@ def test_bulk_analyze_conversations_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_bulk_delete_conversations_rest_bad_request( - request_type=contact_center_insights.BulkDeleteConversationsRequest, +def test_query_metrics_rest_bad_request( + request_type=contact_center_insights.QueryMetricsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"location": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29026,23 +54112,23 @@ def test_bulk_delete_conversations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.bulk_delete_conversations(request) + client.query_metrics(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.BulkDeleteConversationsRequest, + contact_center_insights.QueryMetricsRequest, dict, ], ) -def test_bulk_delete_conversations_rest_call_success(request_type): +def test_query_metrics_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"location": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -29056,14 +54142,14 @@ def test_bulk_delete_conversations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.bulk_delete_conversations(request) + response = client.query_metrics(request) # Establish that the response is the type that we expect. json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_bulk_delete_conversations_rest_interceptors(null_interceptor): +def test_query_metrics_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29079,15 +54165,14 @@ def test_bulk_delete_conversations_rest_interceptors(null_interceptor): ) as transcode, mock.patch.object( operation.Operation, "_set_result_from_operation" ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, - "post_bulk_delete_conversations", + transports.ContactCenterInsightsRestInterceptor, "post_query_metrics" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_bulk_delete_conversations" + transports.ContactCenterInsightsRestInterceptor, "pre_query_metrics" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.BulkDeleteConversationsRequest.pb( - contact_center_insights.BulkDeleteConversationsRequest() + pb_message = contact_center_insights.QueryMetricsRequest.pb( + contact_center_insights.QueryMetricsRequest() ) transcode.return_value = { "method": "post", @@ -29101,7 +54186,7 @@ def test_bulk_delete_conversations_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = contact_center_insights.BulkDeleteConversationsRequest() + request = contact_center_insights.QueryMetricsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -29109,7 +54194,7 @@ def test_bulk_delete_conversations_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = operations_pb2.Operation() - client.bulk_delete_conversations( + client.query_metrics( request, metadata=[ ("key", "val"), @@ -29121,14 +54206,16 @@ def test_bulk_delete_conversations_rest_interceptors(null_interceptor): post.assert_called_once() -def test_ingest_conversations_rest_bad_request( - request_type=contact_center_insights.IngestConversationsRequest, +def test_create_qa_question_rest_bad_request( + request_type=contact_center_insights.CreateQaQuestionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29142,44 +54229,157 @@ def test_ingest_conversations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.ingest_conversations(request) + client.create_qa_question(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.IngestConversationsRequest, + contact_center_insights.CreateQaQuestionRequest, dict, ], ) -def test_ingest_conversations_rest_call_success(request_type): +def test_create_qa_question_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + request_init["qa_question"] = { + "name": "name_value", + "abbreviation": "abbreviation_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "question_body": "question_body_value", + "answer_instructions": "answer_instructions_value", + "answer_choices": [ + { + "str_value": "str_value_value", + "num_value": 0.972, + "bool_value": True, + "na_value": True, + "key": "key_value", + "score": 0.54, + } + ], + "tags": ["tags_value1", "tags_value2"], + "order": 540, + "metrics": {"accuracy": 0.843}, + "tuning_metadata": { + "total_valid_label_count": 2426, + "dataset_validation_warnings": [1], + "tuning_error": "tuning_error_value", + }, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.CreateQaQuestionRequest.meta.fields[ + "qa_question" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["qa_question"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["qa_question"][field])): + del request_init["qa_question"][field][i][subfield] + else: + del request_init["qa_question"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.ingest_conversations(request) + response = client.create_qa_question(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_ingest_conversations_rest_interceptors(null_interceptor): +def test_create_qa_question_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29193,16 +54393,14 @@ def test_ingest_conversations_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_ingest_conversations" + transports.ContactCenterInsightsRestInterceptor, "post_create_qa_question" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_ingest_conversations" + transports.ContactCenterInsightsRestInterceptor, "pre_create_qa_question" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.IngestConversationsRequest.pb( - contact_center_insights.IngestConversationsRequest() + pb_message = contact_center_insights.CreateQaQuestionRequest.pb( + contact_center_insights.CreateQaQuestionRequest() ) transcode.return_value = { "method": "post", @@ -29213,18 +54411,18 @@ def test_ingest_conversations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = resources.QaQuestion.to_json(resources.QaQuestion()) req.return_value.content = return_value - request = contact_center_insights.IngestConversationsRequest() + request = contact_center_insights.CreateQaQuestionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = resources.QaQuestion() - client.ingest_conversations( + client.create_qa_question( request, metadata=[ ("key", "val"), @@ -29236,14 +54434,16 @@ def test_ingest_conversations_rest_interceptors(null_interceptor): post.assert_called_once() -def test_export_insights_data_rest_bad_request( - request_type=contact_center_insights.ExportInsightsDataRequest, +def test_get_qa_question_rest_bad_request( + request_type=contact_center_insights.GetQaQuestionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29257,44 +54457,62 @@ def test_export_insights_data_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.export_insights_data(request) + client.get_qa_question(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ExportInsightsDataRequest, + contact_center_insights.GetQaQuestionRequest, dict, ], ) -def test_export_insights_data_rest_call_success(request_type): +def test_get_qa_question_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.export_insights_data(request) + response = client.get_qa_question(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_export_insights_data_rest_interceptors(null_interceptor): +def test_get_qa_question_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29308,16 +54526,14 @@ def test_export_insights_data_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_export_insights_data" + transports.ContactCenterInsightsRestInterceptor, "post_get_qa_question" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_export_insights_data" + transports.ContactCenterInsightsRestInterceptor, "pre_get_qa_question" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ExportInsightsDataRequest.pb( - contact_center_insights.ExportInsightsDataRequest() + pb_message = contact_center_insights.GetQaQuestionRequest.pb( + contact_center_insights.GetQaQuestionRequest() ) transcode.return_value = { "method": "post", @@ -29328,18 +54544,18 @@ def test_export_insights_data_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = resources.QaQuestion.to_json(resources.QaQuestion()) req.return_value.content = return_value - request = contact_center_insights.ExportInsightsDataRequest() + request = contact_center_insights.GetQaQuestionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = resources.QaQuestion() - client.export_insights_data( + client.get_qa_question( request, metadata=[ ("key", "val"), @@ -29351,14 +54567,18 @@ def test_export_insights_data_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_issue_model_rest_bad_request( - request_type=contact_center_insights.CreateIssueModelRequest, +def test_update_qa_question_rest_bad_request( + request_type=contact_center_insights.UpdateQaQuestionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "qa_question": { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" + } + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29372,50 +54592,60 @@ def test_create_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.create_issue_model(request) + client.update_qa_question(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.CreateIssueModelRequest, + contact_center_insights.UpdateQaQuestionRequest, dict, ], ) -def test_create_issue_model_rest_call_success(request_type): +def test_update_qa_question_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["issue_model"] = { - "name": "name_value", - "display_name": "display_name_value", + request_init = { + "qa_question": { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" + } + } + request_init["qa_question"] = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5", + "abbreviation": "abbreviation_value", "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, - "issue_count": 1201, - "state": 1, - "input_data_config": { - "medium": 1, - "training_conversations_count": 3025, - "filter": "filter_value", - }, - "training_stats": { - "analyzed_conversations_count": 3021, - "unclassified_conversations_count": 3439, - "issue_stats": {}, + "question_body": "question_body_value", + "answer_instructions": "answer_instructions_value", + "answer_choices": [ + { + "str_value": "str_value_value", + "num_value": 0.972, + "bool_value": True, + "na_value": True, + "key": "key_value", + "score": 0.54, + } + ], + "tags": ["tags_value1", "tags_value2"], + "order": 540, + "metrics": {"accuracy": 0.843}, + "tuning_metadata": { + "total_valid_label_count": 2426, + "dataset_validation_warnings": [1], + "tuning_error": "tuning_error_value", }, - "model_type": 1, - "language_code": "language_code_value", } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.CreateIssueModelRequest.meta.fields[ - "issue_model" + test_field = contact_center_insights.UpdateQaQuestionRequest.meta.fields[ + "qa_question" ] def get_message_fields(field): @@ -29444,7 +54674,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["issue_model"].items(): # pragma: NO COVER + for field, value in request_init["qa_question"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -29474,31 +54704,47 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["issue_model"][field])): - del request_init["issue_model"][field][i][subfield] + for i in range(0, len(request_init["qa_question"][field])): + del request_init["qa_question"][field][i][subfield] else: - del request_init["issue_model"][field][subfield] + del request_init["qa_question"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = resources.QaQuestion( + name="name_value", + abbreviation="abbreviation_value", + question_body="question_body_value", + answer_instructions="answer_instructions_value", + tags=["tags_value"], + order=540, + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaQuestion.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_issue_model(request) + response = client.update_qa_question(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, resources.QaQuestion) + assert response.name == "name_value" + assert response.abbreviation == "abbreviation_value" + assert response.question_body == "question_body_value" + assert response.answer_instructions == "answer_instructions_value" + assert response.tags == ["tags_value"] + assert response.order == 540 @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_issue_model_rest_interceptors(null_interceptor): +def test_update_qa_question_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29512,16 +54758,14 @@ def test_create_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_create_issue_model" + transports.ContactCenterInsightsRestInterceptor, "post_update_qa_question" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_create_issue_model" + transports.ContactCenterInsightsRestInterceptor, "pre_update_qa_question" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.CreateIssueModelRequest.pb( - contact_center_insights.CreateIssueModelRequest() + pb_message = contact_center_insights.UpdateQaQuestionRequest.pb( + contact_center_insights.UpdateQaQuestionRequest() ) transcode.return_value = { "method": "post", @@ -29532,18 +54776,18 @@ def test_create_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = resources.QaQuestion.to_json(resources.QaQuestion()) req.return_value.content = return_value - request = contact_center_insights.CreateIssueModelRequest() + request = contact_center_insights.UpdateQaQuestionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = resources.QaQuestion() - client.create_issue_model( + client.update_qa_question( request, metadata=[ ("key", "val"), @@ -29555,17 +54799,15 @@ def test_create_issue_model_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_issue_model_rest_bad_request( - request_type=contact_center_insights.UpdateIssueModelRequest, +def test_delete_qa_question_rest_bad_request( + request_type=contact_center_insights.DeleteQaQuestionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "issue_model": { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" } request = request_type(**request_init) @@ -29580,128 +54822,142 @@ def test_update_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_issue_model(request) + client.delete_qa_question(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UpdateIssueModelRequest, + contact_center_insights.DeleteQaQuestionRequest, dict, ], ) -def test_update_issue_model_rest_call_success(request_type): +def test_delete_qa_question_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "issue_model": { - "name": "projects/sample1/locations/sample2/issueModels/sample3" - } - } - request_init["issue_model"] = { - "name": "projects/sample1/locations/sample2/issueModels/sample3", - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "issue_count": 1201, - "state": 1, - "input_data_config": { - "medium": 1, - "training_conversations_count": 3025, - "filter": "filter_value", - }, - "training_stats": { - "analyzed_conversations_count": 3021, - "unclassified_conversations_count": 3439, - "issue_stats": {}, - }, - "model_type": 1, - "language_code": "language_code_value", + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4/qaQuestions/sample5" } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 + request = request_type(**request_init) - # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.UpdateIssueModelRequest.meta.fields[ - "issue_model" - ] + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "" + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_qa_question(request) - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + # Establish that the response is the type that we expect. + assert response is None - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_qa_question_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) - subfields_not_in_runtime = [] + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, "pre_delete_qa_question" + ) as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteQaQuestionRequest.pb( + contact_center_insights.DeleteQaQuestionRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["issue_model"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + req.return_value = mock.Mock() + req.return_value.status_code = 200 - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) + request = contact_center_insights.DeleteQaQuestionRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["issue_model"][field])): - del request_init["issue_model"][field][i][subfield] - else: - del request_init["issue_model"][field][subfield] + client.delete_qa_question( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_list_qa_questions_rest_bad_request( + request_type=contact_center_insights.ListQaQuestionsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_qa_questions(request) + + +@pytest.mark.parametrize( + "request_type", + [ + contact_center_insights.ListQaQuestionsRequest, + dict, + ], +) +def test_list_qa_questions_rest_call_success(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.IssueModel( - name="name_value", - display_name="display_name_value", - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code="language_code_value", + return_value = contact_center_insights.ListQaQuestionsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -29709,24 +54965,19 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.IssueModel.pb(return_value) + return_value = contact_center_insights.ListQaQuestionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_issue_model(request) + response = client.list_qa_questions(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == "language_code_value" + assert isinstance(response, pagers.ListQaQuestionsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_issue_model_rest_interceptors(null_interceptor): +def test_list_qa_questions_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29740,14 +54991,14 @@ def test_update_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_update_issue_model" + transports.ContactCenterInsightsRestInterceptor, "post_list_qa_questions" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_update_issue_model" + transports.ContactCenterInsightsRestInterceptor, "pre_list_qa_questions" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.UpdateIssueModelRequest.pb( - contact_center_insights.UpdateIssueModelRequest() + pb_message = contact_center_insights.ListQaQuestionsRequest.pb( + contact_center_insights.ListQaQuestionsRequest() ) transcode.return_value = { "method": "post", @@ -29758,18 +55009,20 @@ def test_update_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.IssueModel.to_json(resources.IssueModel()) + return_value = contact_center_insights.ListQaQuestionsResponse.to_json( + contact_center_insights.ListQaQuestionsResponse() + ) req.return_value.content = return_value - request = contact_center_insights.UpdateIssueModelRequest() + request = contact_center_insights.ListQaQuestionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.IssueModel() + post.return_value = contact_center_insights.ListQaQuestionsResponse() - client.update_issue_model( + client.list_qa_questions( request, metadata=[ ("key", "val"), @@ -29781,14 +55034,14 @@ def test_update_issue_model_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_issue_model_rest_bad_request( - request_type=contact_center_insights.GetIssueModelRequest, +def test_create_qa_scorecard_rest_bad_request( + request_type=contact_center_insights.CreateQaScorecardRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29802,35 +55055,108 @@ def test_get_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_issue_model(request) + client.create_qa_scorecard(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetIssueModelRequest, + contact_center_insights.CreateQaScorecardRequest, dict, ], ) -def test_get_issue_model_rest_call_success(request_type): +def test_create_qa_scorecard_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["qa_scorecard"] = { + "name": "name_value", + "display_name": "display_name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.CreateQaScorecardRequest.meta.fields[ + "qa_scorecard" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["qa_scorecard"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["qa_scorecard"][field])): + del request_init["qa_scorecard"][field][i][subfield] + else: + del request_init["qa_scorecard"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.IssueModel( + return_value = resources.QaScorecard( name="name_value", display_name="display_name_value", - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code="language_code_value", + description="description_value", ) # Wrap the value into a proper Response obj @@ -29838,24 +55164,21 @@ def test_get_issue_model_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.IssueModel.pb(return_value) + return_value = resources.QaScorecard.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_issue_model(request) + response = client.create_qa_scorecard(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) + assert isinstance(response, resources.QaScorecard) assert response.name == "name_value" assert response.display_name == "display_name_value" - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == "language_code_value" + assert response.description == "description_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_issue_model_rest_interceptors(null_interceptor): +def test_create_qa_scorecard_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29869,14 +55192,14 @@ def test_get_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_issue_model" + transports.ContactCenterInsightsRestInterceptor, "post_create_qa_scorecard" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_issue_model" + transports.ContactCenterInsightsRestInterceptor, "pre_create_qa_scorecard" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.GetIssueModelRequest.pb( - contact_center_insights.GetIssueModelRequest() + pb_message = contact_center_insights.CreateQaScorecardRequest.pb( + contact_center_insights.CreateQaScorecardRequest() ) transcode.return_value = { "method": "post", @@ -29887,18 +55210,18 @@ def test_get_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.IssueModel.to_json(resources.IssueModel()) + return_value = resources.QaScorecard.to_json(resources.QaScorecard()) req.return_value.content = return_value - request = contact_center_insights.GetIssueModelRequest() + request = contact_center_insights.CreateQaScorecardRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.IssueModel() + post.return_value = resources.QaScorecard() - client.get_issue_model( + client.create_qa_scorecard( request, metadata=[ ("key", "val"), @@ -29910,14 +55233,14 @@ def test_get_issue_model_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_issue_models_rest_bad_request( - request_type=contact_center_insights.ListIssueModelsRequest, +def test_get_qa_scorecard_rest_bad_request( + request_type=contact_center_insights.GetQaScorecardRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/qaScorecards/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29931,47 +55254,54 @@ def test_list_issue_models_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_issue_models(request) + client.get_qa_scorecard(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ListIssueModelsRequest, + contact_center_insights.GetQaScorecardRequest, dict, ], ) -def test_list_issue_models_rest_call_success(request_type): +def test_get_qa_scorecard_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/qaScorecards/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssueModelsResponse() + return_value = resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 # Convert return value to protobuf type - return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) + return_value = resources.QaScorecard.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_issue_models(request) + response = client.get_qa_scorecard(request) # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_issue_models_rest_interceptors(null_interceptor): +def test_get_qa_scorecard_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29985,14 +55315,14 @@ def test_list_issue_models_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_list_issue_models" + transports.ContactCenterInsightsRestInterceptor, "post_get_qa_scorecard" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_list_issue_models" + transports.ContactCenterInsightsRestInterceptor, "pre_get_qa_scorecard" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ListIssueModelsRequest.pb( - contact_center_insights.ListIssueModelsRequest() + pb_message = contact_center_insights.GetQaScorecardRequest.pb( + contact_center_insights.GetQaScorecardRequest() ) transcode.return_value = { "method": "post", @@ -30003,20 +55333,18 @@ def test_list_issue_models_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = contact_center_insights.ListIssueModelsResponse.to_json( - contact_center_insights.ListIssueModelsResponse() - ) + return_value = resources.QaScorecard.to_json(resources.QaScorecard()) req.return_value.content = return_value - request = contact_center_insights.ListIssueModelsRequest() + request = contact_center_insights.GetQaScorecardRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = contact_center_insights.ListIssueModelsResponse() + post.return_value = resources.QaScorecard() - client.list_issue_models( + client.get_qa_scorecard( request, metadata=[ ("key", "val"), @@ -30028,14 +55356,18 @@ def test_list_issue_models_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_issue_model_rest_bad_request( - request_type=contact_center_insights.DeleteIssueModelRequest, +def test_update_qa_scorecard_rest_bad_request( + request_type=contact_center_insights.UpdateQaScorecardRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = { + "qa_scorecard": { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30049,44 +55381,134 @@ def test_delete_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_issue_model(request) + client.update_qa_scorecard(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.DeleteIssueModelRequest, + contact_center_insights.UpdateQaScorecardRequest, dict, ], ) -def test_delete_issue_model_rest_call_success(request_type): +def test_update_qa_scorecard_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = { + "qa_scorecard": { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3" + } + } + request_init["qa_scorecard"] = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3", + "display_name": "display_name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.UpdateQaScorecardRequest.meta.fields[ + "qa_scorecard" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["qa_scorecard"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["qa_scorecard"][field])): + del request_init["qa_scorecard"][field][i][subfield] + else: + del request_init["qa_scorecard"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = resources.QaScorecard( + name="name_value", + display_name="display_name_value", + description="description_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecard.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_issue_model(request) + response = client.update_qa_scorecard(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, resources.QaScorecard) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_issue_model_rest_interceptors(null_interceptor): +def test_update_qa_scorecard_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30100,16 +55522,14 @@ def test_delete_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_delete_issue_model" + transports.ContactCenterInsightsRestInterceptor, "post_update_qa_scorecard" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue_model" + transports.ContactCenterInsightsRestInterceptor, "pre_update_qa_scorecard" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.DeleteIssueModelRequest.pb( - contact_center_insights.DeleteIssueModelRequest() + pb_message = contact_center_insights.UpdateQaScorecardRequest.pb( + contact_center_insights.UpdateQaScorecardRequest() ) transcode.return_value = { "method": "post", @@ -30120,18 +55540,18 @@ def test_delete_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = resources.QaScorecard.to_json(resources.QaScorecard()) req.return_value.content = return_value - request = contact_center_insights.DeleteIssueModelRequest() + request = contact_center_insights.UpdateQaScorecardRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = resources.QaScorecard() - client.delete_issue_model( + client.update_qa_scorecard( request, metadata=[ ("key", "val"), @@ -30143,14 +55563,14 @@ def test_delete_issue_model_rest_interceptors(null_interceptor): post.assert_called_once() -def test_deploy_issue_model_rest_bad_request( - request_type=contact_center_insights.DeployIssueModelRequest, +def test_delete_qa_scorecard_rest_bad_request( + request_type=contact_center_insights.DeleteQaScorecardRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/qaScorecards/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30164,44 +55584,44 @@ def test_deploy_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.deploy_issue_model(request) + client.delete_qa_scorecard(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.DeployIssueModelRequest, + contact_center_insights.DeleteQaScorecardRequest, dict, ], ) -def test_deploy_issue_model_rest_call_success(request_type): +def test_delete_qa_scorecard_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/qaScorecards/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.deploy_issue_model(request) + response = client.delete_qa_scorecard(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_deploy_issue_model_rest_interceptors(null_interceptor): +def test_delete_qa_scorecard_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30215,16 +55635,11 @@ def test_deploy_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_deploy_issue_model" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_deploy_issue_model" + transports.ContactCenterInsightsRestInterceptor, "pre_delete_qa_scorecard" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.DeployIssueModelRequest.pb( - contact_center_insights.DeployIssueModelRequest() + pb_message = contact_center_insights.DeleteQaScorecardRequest.pb( + contact_center_insights.DeleteQaScorecardRequest() ) transcode.return_value = { "method": "post", @@ -30235,18 +55650,15 @@ def test_deploy_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - request = contact_center_insights.DeployIssueModelRequest() + request = contact_center_insights.DeleteQaScorecardRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - client.deploy_issue_model( + client.delete_qa_scorecard( request, metadata=[ ("key", "val"), @@ -30255,17 +55667,16 @@ def test_deploy_issue_model_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_undeploy_issue_model_rest_bad_request( - request_type=contact_center_insights.UndeployIssueModelRequest, +def test_list_qa_scorecards_rest_bad_request( + request_type=contact_center_insights.ListQaScorecardsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30279,44 +55690,50 @@ def test_undeploy_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.undeploy_issue_model(request) + client.list_qa_scorecards(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UndeployIssueModelRequest, + contact_center_insights.ListQaScorecardsRequest, dict, ], ) -def test_undeploy_issue_model_rest_call_success(request_type): +def test_list_qa_scorecards_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = contact_center_insights.ListQaScorecardsResponse( + next_page_token="next_page_token_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = contact_center_insights.ListQaScorecardsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.undeploy_issue_model(request) + response = client.list_qa_scorecards(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, pagers.ListQaScorecardsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_undeploy_issue_model_rest_interceptors(null_interceptor): +def test_list_qa_scorecards_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30330,16 +55747,14 @@ def test_undeploy_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_undeploy_issue_model" + transports.ContactCenterInsightsRestInterceptor, "post_list_qa_scorecards" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_undeploy_issue_model" + transports.ContactCenterInsightsRestInterceptor, "pre_list_qa_scorecards" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.UndeployIssueModelRequest.pb( - contact_center_insights.UndeployIssueModelRequest() + pb_message = contact_center_insights.ListQaScorecardsRequest.pb( + contact_center_insights.ListQaScorecardsRequest() ) transcode.return_value = { "method": "post", @@ -30350,18 +55765,20 @@ def test_undeploy_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = contact_center_insights.ListQaScorecardsResponse.to_json( + contact_center_insights.ListQaScorecardsResponse() + ) req.return_value.content = return_value - request = contact_center_insights.UndeployIssueModelRequest() + request = contact_center_insights.ListQaScorecardsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = contact_center_insights.ListQaScorecardsResponse() - client.undeploy_issue_model( + client.list_qa_scorecards( request, metadata=[ ("key", "val"), @@ -30373,14 +55790,14 @@ def test_undeploy_issue_model_rest_interceptors(null_interceptor): post.assert_called_once() -def test_export_issue_model_rest_bad_request( - request_type=contact_center_insights.ExportIssueModelRequest, +def test_create_qa_scorecard_revision_rest_bad_request( + request_type=contact_center_insights.CreateQaScorecardRevisionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2/qaScorecards/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30394,44 +55811,138 @@ def test_export_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.export_issue_model(request) + client.create_qa_scorecard_revision(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ExportIssueModelRequest, + contact_center_insights.CreateQaScorecardRevisionRequest, dict, ], ) -def test_export_issue_model_rest_call_success(request_type): +def test_create_qa_scorecard_revision_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2/qaScorecards/sample3"} + request_init["qa_scorecard_revision"] = { + "name": "name_value", + "snapshot": { + "name": "name_value", + "display_name": "display_name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + }, + "create_time": {}, + "alternate_ids": ["alternate_ids_value1", "alternate_ids_value2"], + "state": 12, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = contact_center_insights.CreateQaScorecardRevisionRequest.meta.fields[ + "qa_scorecard_revision" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "qa_scorecard_revision" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["qa_scorecard_revision"][field])): + del request_init["qa_scorecard_revision"][field][i][subfield] + else: + del request_init["qa_scorecard_revision"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.export_issue_model(request) + response = client.create_qa_scorecard_revision(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_export_issue_model_rest_interceptors(null_interceptor): +def test_create_qa_scorecard_revision_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30445,16 +55956,16 @@ def test_export_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_export_issue_model" + transports.ContactCenterInsightsRestInterceptor, + "post_create_qa_scorecard_revision", ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_export_issue_model" + transports.ContactCenterInsightsRestInterceptor, + "pre_create_qa_scorecard_revision", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ExportIssueModelRequest.pb( - contact_center_insights.ExportIssueModelRequest() + pb_message = contact_center_insights.CreateQaScorecardRevisionRequest.pb( + contact_center_insights.CreateQaScorecardRevisionRequest() ) transcode.return_value = { "method": "post", @@ -30465,18 +55976,20 @@ def test_export_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = resources.QaScorecardRevision.to_json( + resources.QaScorecardRevision() + ) req.return_value.content = return_value - request = contact_center_insights.ExportIssueModelRequest() + request = contact_center_insights.CreateQaScorecardRevisionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = resources.QaScorecardRevision() - client.export_issue_model( + client.create_qa_scorecard_revision( request, metadata=[ ("key", "val"), @@ -30488,14 +56001,16 @@ def test_export_issue_model_rest_interceptors(null_interceptor): post.assert_called_once() -def test_import_issue_model_rest_bad_request( - request_type=contact_center_insights.ImportIssueModelRequest, +def test_get_qa_scorecard_revision_rest_bad_request( + request_type=contact_center_insights.GetQaScorecardRevisionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30509,44 +56024,56 @@ def test_import_issue_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.import_issue_model(request) + client.get_qa_scorecard_revision(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ImportIssueModelRequest, + contact_center_insights.GetQaScorecardRevisionRequest, dict, ], ) -def test_import_issue_model_rest_call_success(request_type): +def test_get_qa_scorecard_revision_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = resources.QaScorecardRevision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.import_issue_model(request) + response = client.get_qa_scorecard_revision(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_issue_model_rest_interceptors(null_interceptor): +def test_get_qa_scorecard_revision_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30560,16 +56087,15 @@ def test_import_issue_model_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_import_issue_model" + transports.ContactCenterInsightsRestInterceptor, + "post_get_qa_scorecard_revision", ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_import_issue_model" + transports.ContactCenterInsightsRestInterceptor, "pre_get_qa_scorecard_revision" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ImportIssueModelRequest.pb( - contact_center_insights.ImportIssueModelRequest() + pb_message = contact_center_insights.GetQaScorecardRevisionRequest.pb( + contact_center_insights.GetQaScorecardRevisionRequest() ) transcode.return_value = { "method": "post", @@ -30580,18 +56106,20 @@ def test_import_issue_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = resources.QaScorecardRevision.to_json( + resources.QaScorecardRevision() + ) req.return_value.content = return_value - request = contact_center_insights.ImportIssueModelRequest() + request = contact_center_insights.GetQaScorecardRevisionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = resources.QaScorecardRevision() - client.import_issue_model( + client.get_qa_scorecard_revision( request, metadata=[ ("key", "val"), @@ -30603,15 +56131,15 @@ def test_import_issue_model_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_issue_rest_bad_request( - request_type=contact_center_insights.GetIssueRequest, +def test_tune_qa_scorecard_revision_rest_bad_request( + request_type=contact_center_insights.TuneQaScorecardRevisionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" } request = request_type(**request_init) @@ -30626,58 +56154,46 @@ def test_get_issue_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_issue(request) + client.tune_qa_scorecard_revision(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetIssueRequest, + contact_center_insights.TuneQaScorecardRevisionRequest, dict, ], ) -def test_get_issue_rest_call_success(request_type): +def test_tune_qa_scorecard_revision_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + "parent": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Issue( - name="name_value", - display_name="display_name_value", - sample_utterances=["sample_utterances_value"], - display_description="display_description_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.Issue.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_issue(request) + response = client.tune_qa_scorecard_revision(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.sample_utterances == ["sample_utterances_value"] - assert response.display_description == "display_description_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_issue_rest_interceptors(null_interceptor): +def test_tune_qa_scorecard_revision_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30691,14 +56207,18 @@ def test_get_issue_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_issue" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "post_tune_qa_scorecard_revision", ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_issue" + transports.ContactCenterInsightsRestInterceptor, + "pre_tune_qa_scorecard_revision", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.GetIssueRequest.pb( - contact_center_insights.GetIssueRequest() + pb_message = contact_center_insights.TuneQaScorecardRevisionRequest.pb( + contact_center_insights.TuneQaScorecardRevisionRequest() ) transcode.return_value = { "method": "post", @@ -30709,18 +56229,18 @@ def test_get_issue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Issue.to_json(resources.Issue()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = contact_center_insights.GetIssueRequest() + request = contact_center_insights.TuneQaScorecardRevisionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Issue() + post.return_value = operations_pb2.Operation() - client.get_issue( + client.tune_qa_scorecard_revision( request, metadata=[ ("key", "val"), @@ -30732,14 +56252,16 @@ def test_get_issue_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_issues_rest_bad_request( - request_type=contact_center_insights.ListIssuesRequest, +def test_deploy_qa_scorecard_revision_rest_bad_request( + request_type=contact_center_insights.DeployQaScorecardRevisionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30753,47 +56275,56 @@ def test_list_issues_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_issues(request) + client.deploy_qa_scorecard_revision(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ListIssuesRequest, + contact_center_insights.DeployQaScorecardRevisionRequest, dict, ], ) -def test_list_issues_rest_call_success(request_type): +def test_deploy_qa_scorecard_revision_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/issueModels/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssuesResponse() + return_value = resources.QaScorecardRevision( + name="name_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 # Convert return value to protobuf type - return_value = contact_center_insights.ListIssuesResponse.pb(return_value) + return_value = resources.QaScorecardRevision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_issues(request) + response = client.deploy_qa_scorecard_revision(request) # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssuesResponse) + assert isinstance(response, resources.QaScorecardRevision) + assert response.name == "name_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_issues_rest_interceptors(null_interceptor): +def test_deploy_qa_scorecard_revision_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30807,14 +56338,16 @@ def test_list_issues_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_list_issues" + transports.ContactCenterInsightsRestInterceptor, + "post_deploy_qa_scorecard_revision", ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_list_issues" + transports.ContactCenterInsightsRestInterceptor, + "pre_deploy_qa_scorecard_revision", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ListIssuesRequest.pb( - contact_center_insights.ListIssuesRequest() + pb_message = contact_center_insights.DeployQaScorecardRevisionRequest.pb( + contact_center_insights.DeployQaScorecardRevisionRequest() ) transcode.return_value = { "method": "post", @@ -30825,20 +56358,20 @@ def test_list_issues_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = contact_center_insights.ListIssuesResponse.to_json( - contact_center_insights.ListIssuesResponse() + return_value = resources.QaScorecardRevision.to_json( + resources.QaScorecardRevision() ) req.return_value.content = return_value - request = contact_center_insights.ListIssuesRequest() + request = contact_center_insights.DeployQaScorecardRevisionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = contact_center_insights.ListIssuesResponse() + post.return_value = resources.QaScorecardRevision() - client.list_issues( + client.deploy_qa_scorecard_revision( request, metadata=[ ("key", "val"), @@ -30850,17 +56383,15 @@ def test_list_issues_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_issue_rest_bad_request( - request_type=contact_center_insights.UpdateIssueRequest, +def test_undeploy_qa_scorecard_revision_rest_bad_request( + request_type=contact_center_insights.UndeployQaScorecardRevisionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "issue": { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" - } + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" } request = request_type(**request_init) @@ -30875,112 +56406,34 @@ def test_update_issue_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_issue(request) + client.undeploy_qa_scorecard_revision(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UpdateIssueRequest, + contact_center_insights.UndeployQaScorecardRevisionRequest, dict, ], ) -def test_update_issue_rest_call_success(request_type): +def test_undeploy_qa_scorecard_revision_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "issue": { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" - } - } - request_init["issue"] = { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4", - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "sample_utterances": ["sample_utterances_value1", "sample_utterances_value2"], - "display_description": "display_description_value", + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.UpdateIssueRequest.meta.fields["issue"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["issue"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["issue"][field])): - del request_init["issue"][field][i][subfield] - else: - del request_init["issue"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Issue( + return_value = resources.QaScorecardRevision( name="name_value", - display_name="display_name_value", - sample_utterances=["sample_utterances_value"], - display_description="display_description_value", + alternate_ids=["alternate_ids_value"], + state=resources.QaScorecardRevision.State.EDITABLE, ) # Wrap the value into a proper Response obj @@ -30988,22 +56441,21 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.Issue.pb(return_value) + return_value = resources.QaScorecardRevision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_issue(request) + response = client.undeploy_qa_scorecard_revision(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) + assert isinstance(response, resources.QaScorecardRevision) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.sample_utterances == ["sample_utterances_value"] - assert response.display_description == "display_description_value" + assert response.alternate_ids == ["alternate_ids_value"] + assert response.state == resources.QaScorecardRevision.State.EDITABLE @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_issue_rest_interceptors(null_interceptor): +def test_undeploy_qa_scorecard_revision_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31017,14 +56469,16 @@ def test_update_issue_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_update_issue" + transports.ContactCenterInsightsRestInterceptor, + "post_undeploy_qa_scorecard_revision", ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_update_issue" + transports.ContactCenterInsightsRestInterceptor, + "pre_undeploy_qa_scorecard_revision", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.UpdateIssueRequest.pb( - contact_center_insights.UpdateIssueRequest() + pb_message = contact_center_insights.UndeployQaScorecardRevisionRequest.pb( + contact_center_insights.UndeployQaScorecardRevisionRequest() ) transcode.return_value = { "method": "post", @@ -31035,18 +56489,20 @@ def test_update_issue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Issue.to_json(resources.Issue()) + return_value = resources.QaScorecardRevision.to_json( + resources.QaScorecardRevision() + ) req.return_value.content = return_value - request = contact_center_insights.UpdateIssueRequest() + request = contact_center_insights.UndeployQaScorecardRevisionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Issue() + post.return_value = resources.QaScorecardRevision() - client.update_issue( + client.undeploy_qa_scorecard_revision( request, metadata=[ ("key", "val"), @@ -31058,15 +56514,15 @@ def test_update_issue_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_issue_rest_bad_request( - request_type=contact_center_insights.DeleteIssueRequest, +def test_delete_qa_scorecard_revision_rest_bad_request( + request_type=contact_center_insights.DeleteQaScorecardRevisionRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" } request = request_type(**request_init) @@ -31081,24 +56537,24 @@ def test_delete_issue_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_issue(request) + client.delete_qa_scorecard_revision(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.DeleteIssueRequest, + contact_center_insights.DeleteQaScorecardRevisionRequest, dict, ], ) -def test_delete_issue_rest_call_success(request_type): +def test_delete_qa_scorecard_revision_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/issueModels/sample3/issues/sample4" + "name": "projects/sample1/locations/sample2/qaScorecards/sample3/revisions/sample4" } request = request_type(**request_init) @@ -31113,14 +56569,14 @@ def test_delete_issue_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_issue(request) + response = client.delete_qa_scorecard_revision(request) # Establish that the response is the type that we expect. assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_issue_rest_interceptors(null_interceptor): +def test_delete_qa_scorecard_revision_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31134,11 +56590,12 @@ def test_delete_issue_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue" + transports.ContactCenterInsightsRestInterceptor, + "pre_delete_qa_scorecard_revision", ) as pre: pre.assert_not_called() - pb_message = contact_center_insights.DeleteIssueRequest.pb( - contact_center_insights.DeleteIssueRequest() + pb_message = contact_center_insights.DeleteQaScorecardRevisionRequest.pb( + contact_center_insights.DeleteQaScorecardRevisionRequest() ) transcode.return_value = { "method": "post", @@ -31150,14 +56607,14 @@ def test_delete_issue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - request = contact_center_insights.DeleteIssueRequest() + request = contact_center_insights.DeleteQaScorecardRevisionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - client.delete_issue( + client.delete_qa_scorecard_revision( request, metadata=[ ("key", "val"), @@ -31168,16 +56625,14 @@ def test_delete_issue_rest_interceptors(null_interceptor): pre.assert_called_once() -def test_calculate_issue_model_stats_rest_bad_request( - request_type=contact_center_insights.CalculateIssueModelStatsRequest, +def test_list_qa_scorecard_revisions_rest_bad_request( + request_type=contact_center_insights.ListQaScorecardRevisionsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "issue_model": "projects/sample1/locations/sample2/issueModels/sample3" - } + request_init = {"parent": "projects/sample1/locations/sample2/qaScorecards/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -31191,53 +56646,52 @@ def test_calculate_issue_model_stats_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.calculate_issue_model_stats(request) + client.list_qa_scorecard_revisions(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.CalculateIssueModelStatsRequest, + contact_center_insights.ListQaScorecardRevisionsRequest, dict, ], ) -def test_calculate_issue_model_stats_rest_call_success(request_type): +def test_list_qa_scorecard_revisions_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "issue_model": "projects/sample1/locations/sample2/issueModels/sample3" - } + request_init = {"parent": "projects/sample1/locations/sample2/qaScorecards/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateIssueModelStatsResponse() + return_value = contact_center_insights.ListQaScorecardRevisionsResponse( + next_page_token="next_page_token_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 # Convert return value to protobuf type - return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb( + return_value = contact_center_insights.ListQaScorecardRevisionsResponse.pb( return_value ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.calculate_issue_model_stats(request) + response = client.list_qa_scorecard_revisions(request) # Establish that the response is the type that we expect. - assert isinstance( - response, contact_center_insights.CalculateIssueModelStatsResponse - ) + assert isinstance(response, pagers.ListQaScorecardRevisionsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_calculate_issue_model_stats_rest_interceptors(null_interceptor): +def test_list_qa_scorecard_revisions_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31252,15 +56706,15 @@ def test_calculate_issue_model_stats_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.ContactCenterInsightsRestInterceptor, - "post_calculate_issue_model_stats", + "post_list_qa_scorecard_revisions", ) as post, mock.patch.object( transports.ContactCenterInsightsRestInterceptor, - "pre_calculate_issue_model_stats", + "pre_list_qa_scorecard_revisions", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.CalculateIssueModelStatsRequest.pb( - contact_center_insights.CalculateIssueModelStatsRequest() + pb_message = contact_center_insights.ListQaScorecardRevisionsRequest.pb( + contact_center_insights.ListQaScorecardRevisionsRequest() ) transcode.return_value = { "method": "post", @@ -31271,20 +56725,20 @@ def test_calculate_issue_model_stats_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = contact_center_insights.CalculateIssueModelStatsResponse.to_json( - contact_center_insights.CalculateIssueModelStatsResponse() + return_value = contact_center_insights.ListQaScorecardRevisionsResponse.to_json( + contact_center_insights.ListQaScorecardRevisionsResponse() ) req.return_value.content = return_value - request = contact_center_insights.CalculateIssueModelStatsRequest() + request = contact_center_insights.ListQaScorecardRevisionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + post.return_value = contact_center_insights.ListQaScorecardRevisionsResponse() - client.calculate_issue_model_stats( + client.list_qa_scorecard_revisions( request, metadata=[ ("key", "val"), @@ -31296,14 +56750,16 @@ def test_calculate_issue_model_stats_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_phrase_matcher_rest_bad_request( - request_type=contact_center_insights.CreatePhraseMatcherRequest, +def test_create_feedback_label_rest_bad_request( + request_type=contact_center_insights.CreateFeedbackLabelRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -31317,45 +56773,40 @@ def test_create_phrase_matcher_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.create_phrase_matcher(request) + client.create_feedback_label(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.CreatePhraseMatcherRequest, + contact_center_insights.CreateFeedbackLabelRequest, dict, ], ) -def test_create_phrase_matcher_rest_call_success(request_type): +def test_create_feedback_label_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["phrase_matcher"] = { + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } + request_init["feedback_label"] = { + "label": "label_value", + "qa_answer_label": { + "str_value": "str_value_value", + "num_value": 0.972, + "bool_value": True, + "na_value": True, + "key": "key_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + }, "name": "name_value", - "revision_id": "revision_id_value", - "version_tag": "version_tag_value", - "revision_create_time": {"seconds": 751, "nanos": 543}, - "display_name": "display_name_value", - "type_": 1, - "active": True, - "phrase_match_rule_groups": [ - { - "type_": 1, - "phrase_match_rules": [ - { - "query": "query_value", - "negated": True, - "config": {"exact_match_config": {"case_sensitive": True}}, - } - ], - } - ], - "activation_update_time": {}, - "role_match": 1, + "labeled_resource": "labeled_resource_value", + "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -31363,8 +56814,8 @@ def test_create_phrase_matcher_rest_call_success(request_type): # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.CreatePhraseMatcherRequest.meta.fields[ - "phrase_matcher" + test_field = contact_center_insights.CreateFeedbackLabelRequest.meta.fields[ + "feedback_label" ] def get_message_fields(field): @@ -31393,7 +56844,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["phrase_matcher"].items(): # pragma: NO COVER + for field, value in request_init["feedback_label"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -31423,23 +56874,19 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["phrase_matcher"][field])): - del request_init["phrase_matcher"][field][i][subfield] + for i in range(0, len(request_init["feedback_label"][field])): + del request_init["feedback_label"][field][i][subfield] else: - del request_init["phrase_matcher"][field][subfield] + del request_init["feedback_label"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher( + return_value = resources.FeedbackLabel( name="name_value", - revision_id="revision_id_value", - version_tag="version_tag_value", - display_name="display_name_value", - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + labeled_resource="labeled_resource_value", + label="label_value", ) # Wrap the value into a proper Response obj @@ -31447,25 +56894,20 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) + return_value = resources.FeedbackLabel.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_phrase_matcher(request) + response = client.create_feedback_label(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) + assert isinstance(response, resources.FeedbackLabel) assert response.name == "name_value" - assert response.revision_id == "revision_id_value" - assert response.version_tag == "version_tag_value" - assert response.display_name == "display_name_value" - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + assert response.labeled_resource == "labeled_resource_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_phrase_matcher_rest_interceptors(null_interceptor): +def test_create_feedback_label_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31479,14 +56921,14 @@ def test_create_phrase_matcher_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_create_phrase_matcher" + transports.ContactCenterInsightsRestInterceptor, "post_create_feedback_label" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_create_phrase_matcher" + transports.ContactCenterInsightsRestInterceptor, "pre_create_feedback_label" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.CreatePhraseMatcherRequest.pb( - contact_center_insights.CreatePhraseMatcherRequest() + pb_message = contact_center_insights.CreateFeedbackLabelRequest.pb( + contact_center_insights.CreateFeedbackLabelRequest() ) transcode.return_value = { "method": "post", @@ -31497,18 +56939,18 @@ def test_create_phrase_matcher_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + return_value = resources.FeedbackLabel.to_json(resources.FeedbackLabel()) req.return_value.content = return_value - request = contact_center_insights.CreatePhraseMatcherRequest() + request = contact_center_insights.CreateFeedbackLabelRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.PhraseMatcher() + post.return_value = resources.FeedbackLabel() - client.create_phrase_matcher( + client.create_feedback_label( request, metadata=[ ("key", "val"), @@ -31520,14 +56962,16 @@ def test_create_phrase_matcher_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_phrase_matcher_rest_bad_request( - request_type=contact_center_insights.GetPhraseMatcherRequest, +def test_list_feedback_labels_rest_bad_request( + request_type=contact_center_insights.ListFeedbackLabelsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -31541,36 +56985,32 @@ def test_get_phrase_matcher_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_phrase_matcher(request) + client.list_feedback_labels(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetPhraseMatcherRequest, + contact_center_insights.ListFeedbackLabelsRequest, dict, ], ) -def test_get_phrase_matcher_rest_call_success(request_type): +def test_list_feedback_labels_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/conversations/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher( - name="name_value", - revision_id="revision_id_value", - version_tag="version_tag_value", - display_name="display_name_value", - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + return_value = contact_center_insights.ListFeedbackLabelsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -31578,25 +57018,21 @@ def test_get_phrase_matcher_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) + return_value = contact_center_insights.ListFeedbackLabelsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_phrase_matcher(request) + response = client.list_feedback_labels(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == "name_value" - assert response.revision_id == "revision_id_value" - assert response.version_tag == "version_tag_value" - assert response.display_name == "display_name_value" - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + assert isinstance(response, pagers.ListFeedbackLabelsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_phrase_matcher_rest_interceptors(null_interceptor): +def test_list_feedback_labels_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31610,14 +57046,14 @@ def test_get_phrase_matcher_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_phrase_matcher" + transports.ContactCenterInsightsRestInterceptor, "post_list_feedback_labels" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_phrase_matcher" + transports.ContactCenterInsightsRestInterceptor, "pre_list_feedback_labels" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.GetPhraseMatcherRequest.pb( - contact_center_insights.GetPhraseMatcherRequest() + pb_message = contact_center_insights.ListFeedbackLabelsRequest.pb( + contact_center_insights.ListFeedbackLabelsRequest() ) transcode.return_value = { "method": "post", @@ -31628,18 +57064,20 @@ def test_get_phrase_matcher_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + return_value = contact_center_insights.ListFeedbackLabelsResponse.to_json( + contact_center_insights.ListFeedbackLabelsResponse() + ) req.return_value.content = return_value - request = contact_center_insights.GetPhraseMatcherRequest() + request = contact_center_insights.ListFeedbackLabelsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.PhraseMatcher() + post.return_value = contact_center_insights.ListFeedbackLabelsResponse() - client.get_phrase_matcher( + client.list_feedback_labels( request, metadata=[ ("key", "val"), @@ -31651,14 +57089,16 @@ def test_get_phrase_matcher_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_phrase_matchers_rest_bad_request( - request_type=contact_center_insights.ListPhraseMatchersRequest, +def test_get_feedback_label_rest_bad_request( + request_type=contact_center_insights.GetFeedbackLabelRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -31672,30 +57112,34 @@ def test_list_phrase_matchers_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_phrase_matchers(request) + client.get_feedback_label(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.ListPhraseMatchersRequest, + contact_center_insights.GetFeedbackLabelRequest, dict, ], ) -def test_list_phrase_matchers_rest_call_success(request_type): +def test_get_feedback_label_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListPhraseMatchersResponse( - next_page_token="next_page_token_value", + return_value = resources.FeedbackLabel( + name="name_value", + labeled_resource="labeled_resource_value", + label="label_value", ) # Wrap the value into a proper Response obj @@ -31703,21 +57147,20 @@ def test_list_phrase_matchers_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = contact_center_insights.ListPhraseMatchersResponse.pb( - return_value - ) + return_value = resources.FeedbackLabel.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_phrase_matchers(request) + response = client.get_feedback_label(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPhraseMatchersPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.FeedbackLabel) + assert response.name == "name_value" + assert response.labeled_resource == "labeled_resource_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_phrase_matchers_rest_interceptors(null_interceptor): +def test_get_feedback_label_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31731,14 +57174,14 @@ def test_list_phrase_matchers_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_list_phrase_matchers" + transports.ContactCenterInsightsRestInterceptor, "post_get_feedback_label" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_list_phrase_matchers" + transports.ContactCenterInsightsRestInterceptor, "pre_get_feedback_label" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.ListPhraseMatchersRequest.pb( - contact_center_insights.ListPhraseMatchersRequest() + pb_message = contact_center_insights.GetFeedbackLabelRequest.pb( + contact_center_insights.GetFeedbackLabelRequest() ) transcode.return_value = { "method": "post", @@ -31749,20 +57192,18 @@ def test_list_phrase_matchers_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = contact_center_insights.ListPhraseMatchersResponse.to_json( - contact_center_insights.ListPhraseMatchersResponse() - ) + return_value = resources.FeedbackLabel.to_json(resources.FeedbackLabel()) req.return_value.content = return_value - request = contact_center_insights.ListPhraseMatchersRequest() + request = contact_center_insights.GetFeedbackLabelRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = contact_center_insights.ListPhraseMatchersResponse() + post.return_value = resources.FeedbackLabel() - client.list_phrase_matchers( + client.get_feedback_label( request, metadata=[ ("key", "val"), @@ -31774,122 +57215,16 @@ def test_list_phrase_matchers_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_phrase_matcher_rest_bad_request( - request_type=contact_center_insights.DeletePhraseMatcherRequest, -): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_phrase_matcher(request) - - -@pytest.mark.parametrize( - "request_type", - [ - contact_center_insights.DeletePhraseMatcherRequest, - dict, - ], -) -def test_delete_phrase_matcher_rest_call_success(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/phraseMatchers/sample3"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = "" - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.delete_phrase_matcher(request) - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_phrase_matcher_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_delete_phrase_matcher" - ) as pre: - pre.assert_not_called() - pb_message = contact_center_insights.DeletePhraseMatcherRequest.pb( - contact_center_insights.DeletePhraseMatcherRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - - request = contact_center_insights.DeletePhraseMatcherRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_phrase_matcher( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - - -def test_update_phrase_matcher_rest_bad_request( - request_type=contact_center_insights.UpdatePhraseMatcherRequest, +def test_update_feedback_label_rest_bad_request( + request_type=contact_center_insights.UpdateFeedbackLabelRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "phrase_matcher": { - "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" + "feedback_label": { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" } } request = request_type(**request_init) @@ -31905,49 +57240,42 @@ def test_update_phrase_matcher_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_phrase_matcher(request) + client.update_feedback_label(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UpdatePhraseMatcherRequest, + contact_center_insights.UpdateFeedbackLabelRequest, dict, ], ) -def test_update_phrase_matcher_rest_call_success(request_type): +def test_update_feedback_label_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "phrase_matcher": { - "name": "projects/sample1/locations/sample2/phraseMatchers/sample3" + "feedback_label": { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" } } - request_init["phrase_matcher"] = { - "name": "projects/sample1/locations/sample2/phraseMatchers/sample3", - "revision_id": "revision_id_value", - "version_tag": "version_tag_value", - "revision_create_time": {"seconds": 751, "nanos": 543}, - "display_name": "display_name_value", - "type_": 1, - "active": True, - "phrase_match_rule_groups": [ - { - "type_": 1, - "phrase_match_rules": [ - { - "query": "query_value", - "negated": True, - "config": {"exact_match_config": {"case_sensitive": True}}, - } - ], - } - ], - "activation_update_time": {}, - "role_match": 1, + request_init["feedback_label"] = { + "label": "label_value", + "qa_answer_label": { + "str_value": "str_value_value", + "num_value": 0.972, + "bool_value": True, + "na_value": True, + "key": "key_value", + "score": 0.54, + "potential_score": 0.16110000000000002, + "normalized_score": 0.17120000000000002, + }, + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4", + "labeled_resource": "labeled_resource_value", + "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -31955,8 +57283,8 @@ def test_update_phrase_matcher_rest_call_success(request_type): # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.UpdatePhraseMatcherRequest.meta.fields[ - "phrase_matcher" + test_field = contact_center_insights.UpdateFeedbackLabelRequest.meta.fields[ + "feedback_label" ] def get_message_fields(field): @@ -31985,7 +57313,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["phrase_matcher"].items(): # pragma: NO COVER + for field, value in request_init["feedback_label"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -32015,23 +57343,19 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["phrase_matcher"][field])): - del request_init["phrase_matcher"][field][i][subfield] + for i in range(0, len(request_init["feedback_label"][field])): + del request_init["feedback_label"][field][i][subfield] else: - del request_init["phrase_matcher"][field][subfield] + del request_init["feedback_label"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher( + return_value = resources.FeedbackLabel( name="name_value", - revision_id="revision_id_value", - version_tag="version_tag_value", - display_name="display_name_value", - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + labeled_resource="labeled_resource_value", + label="label_value", ) # Wrap the value into a proper Response obj @@ -32039,25 +57363,20 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.PhraseMatcher.pb(return_value) + return_value = resources.FeedbackLabel.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_phrase_matcher(request) + response = client.update_feedback_label(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) + assert isinstance(response, resources.FeedbackLabel) assert response.name == "name_value" - assert response.revision_id == "revision_id_value" - assert response.version_tag == "version_tag_value" - assert response.display_name == "display_name_value" - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + assert response.labeled_resource == "labeled_resource_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_phrase_matcher_rest_interceptors(null_interceptor): +def test_update_feedback_label_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32071,14 +57390,14 @@ def test_update_phrase_matcher_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_update_phrase_matcher" + transports.ContactCenterInsightsRestInterceptor, "post_update_feedback_label" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_update_phrase_matcher" + transports.ContactCenterInsightsRestInterceptor, "pre_update_feedback_label" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.UpdatePhraseMatcherRequest.pb( - contact_center_insights.UpdatePhraseMatcherRequest() + pb_message = contact_center_insights.UpdateFeedbackLabelRequest.pb( + contact_center_insights.UpdateFeedbackLabelRequest() ) transcode.return_value = { "method": "post", @@ -32089,18 +57408,18 @@ def test_update_phrase_matcher_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + return_value = resources.FeedbackLabel.to_json(resources.FeedbackLabel()) req.return_value.content = return_value - request = contact_center_insights.UpdatePhraseMatcherRequest() + request = contact_center_insights.UpdateFeedbackLabelRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.PhraseMatcher() + post.return_value = resources.FeedbackLabel() - client.update_phrase_matcher( + client.update_feedback_label( request, metadata=[ ("key", "val"), @@ -32112,14 +57431,16 @@ def test_update_phrase_matcher_rest_interceptors(null_interceptor): post.assert_called_once() -def test_calculate_stats_rest_bad_request( - request_type=contact_center_insights.CalculateStatsRequest, +def test_delete_feedback_label_rest_bad_request( + request_type=contact_center_insights.DeleteFeedbackLabelRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"location": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32133,175 +57454,46 @@ def test_calculate_stats_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.calculate_stats(request) + client.delete_feedback_label(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.CalculateStatsRequest, + contact_center_insights.DeleteFeedbackLabelRequest, dict, ], ) -def test_calculate_stats_rest_call_success(request_type): +def test_delete_feedback_label_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"location": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/conversations/sample3/feedbackLabels/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateStatsResponse( - average_turn_count=1931, - conversation_count=1955, - ) + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.calculate_stats(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.CalculateStatsResponse) - assert response.average_turn_count == 1931 - assert response.conversation_count == 1955 - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_calculate_stats_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_calculate_stats" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_calculate_stats" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CalculateStatsRequest.pb( - contact_center_insights.CalculateStatsRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = contact_center_insights.CalculateStatsResponse.to_json( - contact_center_insights.CalculateStatsResponse() - ) - req.return_value.content = return_value - - request = contact_center_insights.CalculateStatsRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.CalculateStatsResponse() - - client.calculate_stats( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_settings_rest_bad_request( - request_type=contact_center_insights.GetSettingsRequest, -): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/settings"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_settings(request) - - -@pytest.mark.parametrize( - "request_type", - [ - contact_center_insights.GetSettingsRequest, - dict, - ], -) -def test_get_settings_rest_call_success(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/settings"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Settings( - name="name_value", - language_code="language_code_value", - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_settings(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == "name_value" - assert response.language_code == "language_code_value" + response = client.delete_feedback_label(request) + + # Establish that the response is the type that we expect. + assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_settings_rest_interceptors(null_interceptor): +def test_delete_feedback_label_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32315,14 +57507,11 @@ def test_get_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_settings" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_settings" + transports.ContactCenterInsightsRestInterceptor, "pre_delete_feedback_label" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetSettingsRequest.pb( - contact_center_insights.GetSettingsRequest() + pb_message = contact_center_insights.DeleteFeedbackLabelRequest.pb( + contact_center_insights.DeleteFeedbackLabelRequest() ) transcode.return_value = { "method": "post", @@ -32333,18 +57522,15 @@ def test_get_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Settings.to_json(resources.Settings()) - req.return_value.content = return_value - request = contact_center_insights.GetSettingsRequest() + request = contact_center_insights.DeleteFeedbackLabelRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Settings() - client.get_settings( + client.delete_feedback_label( request, metadata=[ ("key", "val"), @@ -32353,17 +57539,16 @@ def test_get_settings_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_update_settings_rest_bad_request( - request_type=contact_center_insights.UpdateSettingsRequest, +def test_list_all_feedback_labels_rest_bad_request( + request_type=contact_center_insights.ListAllFeedbackLabelsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"settings": {"name": "projects/sample1/locations/sample2/settings"}} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32377,131 +57562,30 @@ def test_update_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_settings(request) + client.list_all_feedback_labels(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.UpdateSettingsRequest, + contact_center_insights.ListAllFeedbackLabelsRequest, dict, ], ) -def test_update_settings_rest_call_success(request_type): +def test_list_all_feedback_labels_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"settings": {"name": "projects/sample1/locations/sample2/settings"}} - request_init["settings"] = { - "name": "projects/sample1/locations/sample2/settings", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "language_code": "language_code_value", - "conversation_ttl": {"seconds": 751, "nanos": 543}, - "pubsub_notification_settings": {}, - "analysis_config": { - "runtime_integration_analysis_percentage": 0.4167, - "upload_conversation_analysis_percentage": 0.41590000000000005, - "annotator_selector": { - "run_interruption_annotator": True, - "run_silence_annotator": True, - "run_phrase_matcher_annotator": True, - "phrase_matchers": ["phrase_matchers_value1", "phrase_matchers_value2"], - "run_sentiment_annotator": True, - "run_entity_annotator": True, - "run_intent_annotator": True, - "run_issue_model_annotator": True, - "issue_models": ["issue_models_value1", "issue_models_value2"], - "run_summarization_annotator": True, - "summarization_config": { - "conversation_profile": "conversation_profile_value", - "summarization_model": 1, - }, - }, - }, - "redaction_config": { - "deidentify_template": "deidentify_template_value", - "inspect_template": "inspect_template_value", - }, - "speech_config": {"speech_recognizer": "speech_recognizer_value"}, - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.UpdateSettingsRequest.meta.fields["settings"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["settings"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["settings"][field])): - del request_init["settings"][field][i][subfield] - else: - del request_init["settings"][field][subfield] + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Settings( - name="name_value", - language_code="language_code_value", + return_value = contact_center_insights.ListAllFeedbackLabelsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -32509,20 +57593,21 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = resources.Settings.pb(return_value) + return_value = contact_center_insights.ListAllFeedbackLabelsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_settings(request) + response = client.list_all_feedback_labels(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == "name_value" - assert response.language_code == "language_code_value" + assert isinstance(response, pagers.ListAllFeedbackLabelsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_settings_rest_interceptors(null_interceptor): +def test_list_all_feedback_labels_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32536,14 +57621,14 @@ def test_update_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_update_settings" + transports.ContactCenterInsightsRestInterceptor, "post_list_all_feedback_labels" ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_update_settings" + transports.ContactCenterInsightsRestInterceptor, "pre_list_all_feedback_labels" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.UpdateSettingsRequest.pb( - contact_center_insights.UpdateSettingsRequest() + pb_message = contact_center_insights.ListAllFeedbackLabelsRequest.pb( + contact_center_insights.ListAllFeedbackLabelsRequest() ) transcode.return_value = { "method": "post", @@ -32554,18 +57639,20 @@ def test_update_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.Settings.to_json(resources.Settings()) + return_value = contact_center_insights.ListAllFeedbackLabelsResponse.to_json( + contact_center_insights.ListAllFeedbackLabelsResponse() + ) req.return_value.content = return_value - request = contact_center_insights.UpdateSettingsRequest() + request = contact_center_insights.ListAllFeedbackLabelsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Settings() + post.return_value = contact_center_insights.ListAllFeedbackLabelsResponse() - client.update_settings( + client.list_all_feedback_labels( request, metadata=[ ("key", "val"), @@ -32577,14 +57664,14 @@ def test_update_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_encryption_spec_rest_bad_request( - request_type=contact_center_insights.GetEncryptionSpecRequest, +def test_bulk_upload_feedback_labels_rest_bad_request( + request_type=contact_center_insights.BulkUploadFeedbackLabelsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/encryptionSpec"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32598,52 +57685,44 @@ def test_get_encryption_spec_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_encryption_spec(request) + client.bulk_upload_feedback_labels(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.GetEncryptionSpecRequest, + contact_center_insights.BulkUploadFeedbackLabelsRequest, dict, ], ) -def test_get_encryption_spec_rest_call_success(request_type): +def test_bulk_upload_feedback_labels_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/encryptionSpec"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.EncryptionSpec( - name="name_value", - kms_key="kms_key_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = resources.EncryptionSpec.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_encryption_spec(request) + response = client.bulk_upload_feedback_labels(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.EncryptionSpec) - assert response.name == "name_value" - assert response.kms_key == "kms_key_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_encryption_spec_rest_interceptors(null_interceptor): +def test_bulk_upload_feedback_labels_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32657,14 +57736,18 @@ def test_get_encryption_spec_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_encryption_spec" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ContactCenterInsightsRestInterceptor, + "post_bulk_upload_feedback_labels", ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_encryption_spec" + transports.ContactCenterInsightsRestInterceptor, + "pre_bulk_upload_feedback_labels", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.GetEncryptionSpecRequest.pb( - contact_center_insights.GetEncryptionSpecRequest() + pb_message = contact_center_insights.BulkUploadFeedbackLabelsRequest.pb( + contact_center_insights.BulkUploadFeedbackLabelsRequest() ) transcode.return_value = { "method": "post", @@ -32675,18 +57758,18 @@ def test_get_encryption_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = resources.EncryptionSpec.to_json(resources.EncryptionSpec()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = contact_center_insights.GetEncryptionSpecRequest() + request = contact_center_insights.BulkUploadFeedbackLabelsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.EncryptionSpec() + post.return_value = operations_pb2.Operation() - client.get_encryption_spec( + client.bulk_upload_feedback_labels( request, metadata=[ ("key", "val"), @@ -32698,16 +57781,14 @@ def test_get_encryption_spec_rest_interceptors(null_interceptor): post.assert_called_once() -def test_initialize_encryption_spec_rest_bad_request( - request_type=contact_center_insights.InitializeEncryptionSpecRequest, +def test_bulk_download_feedback_labels_rest_bad_request( + request_type=contact_center_insights.BulkDownloadFeedbackLabelsRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "encryption_spec": {"name": "projects/sample1/locations/sample2/encryptionSpec"} - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32721,25 +57802,23 @@ def test_initialize_encryption_spec_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.initialize_encryption_spec(request) + client.bulk_download_feedback_labels(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.InitializeEncryptionSpecRequest, + contact_center_insights.BulkDownloadFeedbackLabelsRequest, dict, ], ) -def test_initialize_encryption_spec_rest_call_success(request_type): +def test_bulk_download_feedback_labels_rest_call_success(request_type): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "encryption_spec": {"name": "projects/sample1/locations/sample2/encryptionSpec"} - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -32753,14 +57832,14 @@ def test_initialize_encryption_spec_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.initialize_encryption_spec(request) + response = client.bulk_download_feedback_labels(request) # Establish that the response is the type that we expect. json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_initialize_encryption_spec_rest_interceptors(null_interceptor): +def test_bulk_download_feedback_labels_rest_interceptors(null_interceptor): transport = transports.ContactCenterInsightsRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32777,15 +57856,15 @@ def test_initialize_encryption_spec_rest_interceptors(null_interceptor): operation.Operation, "_set_result_from_operation" ), mock.patch.object( transports.ContactCenterInsightsRestInterceptor, - "post_initialize_encryption_spec", + "post_bulk_download_feedback_labels", ) as post, mock.patch.object( transports.ContactCenterInsightsRestInterceptor, - "pre_initialize_encryption_spec", + "pre_bulk_download_feedback_labels", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = contact_center_insights.InitializeEncryptionSpecRequest.pb( - contact_center_insights.InitializeEncryptionSpecRequest() + pb_message = contact_center_insights.BulkDownloadFeedbackLabelsRequest.pb( + contact_center_insights.BulkDownloadFeedbackLabelsRequest() ) transcode.return_value = { "method": "post", @@ -32799,7 +57878,7 @@ def test_initialize_encryption_spec_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = contact_center_insights.InitializeEncryptionSpecRequest() + request = contact_center_insights.BulkDownloadFeedbackLabelsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -32807,7 +57886,7 @@ def test_initialize_encryption_spec_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = operations_pb2.Operation() - client.initialize_encryption_spec( + client.bulk_download_feedback_labels( request, metadata=[ ("key", "val"), @@ -32819,942 +57898,858 @@ def test_initialize_encryption_spec_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_view_rest_bad_request( - request_type=contact_center_insights.CreateViewRequest, +def test_cancel_operation_rest_bad_request( + request_type=operations_pb2.CancelOperationRequest, ): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. with mock.patch.object(Session, "request") as req, pytest.raises( core_exceptions.BadRequest ): # Wrap the value into a proper Response obj - response_value = mock.Mock() + response_value = Response() json_return_value = "" response_value.json = mock.Mock(return_value={}) response_value.status_code = 400 - response_value.request = mock.Mock() + response_value.request = Request() req.return_value = response_value - client.create_view(request) + client.cancel_operation(request) @pytest.mark.parametrize( "request_type", [ - contact_center_insights.CreateViewRequest, + operations_pb2.CancelOperationRequest, dict, ], ) -def test_create_view_rest_call_success(request_type): +def test_cancel_operation_rest(request_type): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["view"] = { - "name": "name_value", - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "value": "value_value", - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = None - # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.CreateViewRequest.meta.fields["view"] + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "{}" + response_value.content = json_return_value.encode("UTF-8") - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] + req.return_value = response_value - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + response = client.cancel_operation(request) - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields + # Establish that the response is the type that we expect. + assert response is None - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - subfields_not_in_runtime = [] +def test_get_operation_rest_bad_request( + request_type=operations_pb2.GetOperationRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request + ) - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["view"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_operation(request) - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["view"][field])): - del request_init["view"][field][i][subfield] - else: - del request_init["view"][field][subfield] +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.GetOperationRequest, + dict, + ], +) +def test_get_operation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + + req.return_value = response_value + + response = client.get_operation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_list_operations_rest_bad_request( + request_type=operations_pb2.ListOperationsRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_operations(request) + + +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.ListOperationsRequest, + dict, + ], +) +def test_list_operations_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {"name": "projects/sample1/locations/sample2"} + request = request_type(**request_init) # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: + with mock.patch.object(Session, "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", - ) + return_value = operations_pb2.ListOperationsResponse() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + + req.return_value = response_value + + response = client.list_operations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + + +def test_initialize_client_w_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_conversation_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), "__call__" + ) as call: + client.create_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_upload_conversation_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), "__call__" + ) as call: + client.upload_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UploadConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_conversation_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), "__call__" + ) as call: + client.update_conversation(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateConversationRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_conversation_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_conversation), "__call__") as call: + client.get_conversation(request=None) - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.create_view(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetConversationRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert args[0] == request_msg -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_conversations_empty_call_rest(): + client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.ContactCenterInsightsRestInterceptor(), + transport="rest", ) - client = ContactCenterInsightsClient(transport=transport) + # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_create_view" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_create_view" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CreateViewRequest.pb( - contact_center_insights.CreateViewRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = resources.View.to_json(resources.View()) - req.return_value.content = return_value - - request = contact_center_insights.CreateViewRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.View() + type(client.transport.list_conversations), "__call__" + ) as call: + client.list_conversations(request=None) - client.create_view( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListConversationsRequest() - pre.assert_called_once() - post.assert_called_once() + assert args[0] == request_msg -def test_get_view_rest_bad_request(request_type=contact_center_insights.GetViewRequest): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_conversation_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_view(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), "__call__" + ) as call: + client.delete_conversation(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteConversationRequest() -@pytest.mark.parametrize( - "request_type", - [ - contact_center_insights.GetViewRequest, - dict, - ], -) -def test_get_view_rest_call_success(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_analysis_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} - request = request_type(**request_init) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_analysis), "__call__") as call: + client.create_analysis(request=None) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", - ) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateAnalysisRequest() - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 + assert args[0] == request_msg - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.get_view(request) - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.value == "value_value" +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_analysis_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_analysis), "__call__") as call: + client.get_analysis(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetAnalysisRequest() -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_analyses_empty_call_rest(): + client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.ContactCenterInsightsRestInterceptor(), + transport="rest", ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_get_view" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_get_view" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetViewRequest.pb( - contact_center_insights.GetViewRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_analyses), "__call__") as call: + client.list_analyses(request=None) - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = resources.View.to_json(resources.View()) - req.return_value.content = return_value + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListAnalysesRequest() - request = contact_center_insights.GetViewRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.View() + assert args[0] == request_msg - client.get_view( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - pre.assert_called_once() - post.assert_called_once() +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_analysis_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_analysis), "__call__") as call: + client.delete_analysis(request=None) -def test_list_views_rest_bad_request( - request_type=contact_center_insights.ListViewsRequest, -): + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteAnalysisRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_bulk_analyze_conversations_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_views(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), "__call__" + ) as call: + client.bulk_analyze_conversations(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkAnalyzeConversationsRequest() -@pytest.mark.parametrize( - "request_type", - [ - contact_center_insights.ListViewsRequest, - dict, - ], -) -def test_list_views_rest_call_success(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_bulk_delete_conversations_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request = request_type(**request_init) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.bulk_delete_conversations), "__call__" + ) as call: + client.bulk_delete_conversations(request=None) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListViewsResponse( - next_page_token="next_page_token_value", - ) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.BulkDeleteConversationsRequest() - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 + assert args[0] == request_msg - # Convert return value to protobuf type - return_value = contact_center_insights.ListViewsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.list_views(request) - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListViewsPager) - assert response.next_page_token == "next_page_token_value" +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_ingest_conversations_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), "__call__" + ) as call: + client.ingest_conversations(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.IngestConversationsRequest() + assert args[0] == request_msg -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_views_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_insights_data_empty_call_rest(): + client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.ContactCenterInsightsRestInterceptor(), + transport="rest", ) - client = ContactCenterInsightsClient(transport=transport) + # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_list_views" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_list_views" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ListViewsRequest.pb( - contact_center_insights.ListViewsRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } + type(client.transport.export_insights_data), "__call__" + ) as call: + client.export_insights_data(request=None) - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = contact_center_insights.ListViewsResponse.to_json( - contact_center_insights.ListViewsResponse() - ) - req.return_value.content = return_value + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ExportInsightsDataRequest() - request = contact_center_insights.ListViewsRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.ListViewsResponse() + assert args[0] == request_msg - client.list_views( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - pre.assert_called_once() - post.assert_called_once() +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_issue_model_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + client.create_issue_model(request=None) -def test_update_view_rest_bad_request( - request_type=contact_center_insights.UpdateViewRequest, -): + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreateIssueModelRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_issue_model_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "view": {"name": "projects/sample1/locations/sample2/views/sample3"} - } - request = request_type(**request_init) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_view(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + client.update_issue_model(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateIssueModelRequest() + assert args[0] == request_msg -@pytest.mark.parametrize( - "request_type", - [ - contact_center_insights.UpdateViewRequest, - dict, - ], -) -def test_update_view_rest_call_success(request_type): + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_issue_model_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "view": {"name": "projects/sample1/locations/sample2/views/sample3"} - } - request_init["view"] = { - "name": "projects/sample1/locations/sample2/views/sample3", - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "value": "value_value", - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = contact_center_insights.UpdateViewRequest.meta.fields["view"] + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + client.get_issue_model(request=None) - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetIssueModelRequest() - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + assert args[0] == request_msg - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_issue_models_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) - subfields_not_in_runtime = [] + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + client.list_issue_models(request=None) - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["view"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListIssueModelsRequest() - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) + assert args[0] == request_msg - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["view"][field])): - del request_init["view"][field][i][subfield] - else: - del request_init["view"][field][subfield] - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.View( - name="name_value", - display_name="display_name_value", - value="value_value", - ) +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_issue_model_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + client.delete_issue_model(request=None) - # Convert return value to protobuf type - return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.update_view(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteIssueModelRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.value == "value_value" + assert args[0] == request_msg -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_deploy_issue_model_empty_call_rest(): + client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.ContactCenterInsightsRestInterceptor(), + transport="rest", ) - client = ContactCenterInsightsClient(transport=transport) + # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "post_update_view" - ) as post, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_update_view" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UpdateViewRequest.pb( - contact_center_insights.UpdateViewRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = resources.View.to_json(resources.View()) - req.return_value.content = return_value - - request = contact_center_insights.UpdateViewRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.View() + type(client.transport.deploy_issue_model), "__call__" + ) as call: + client.deploy_issue_model(request=None) - client.update_view( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeployIssueModelRequest() - pre.assert_called_once() - post.assert_called_once() + assert args[0] == request_msg -def test_delete_view_rest_bad_request( - request_type=contact_center_insights.DeleteViewRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_undeploy_issue_model_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_view(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), "__call__" + ) as call: + client.undeploy_issue_model(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UndeployIssueModelRequest() -@pytest.mark.parametrize( - "request_type", - [ - contact_center_insights.DeleteViewRequest, - dict, - ], -) -def test_delete_view_rest_call_success(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_issue_model_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/views/sample3"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_issue_model), "__call__" + ) as call: + client.export_issue_model(request=None) - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = "" - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.delete_view(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ExportIssueModelRequest() - # Establish that the response is the type that we expect. - assert response is None + assert args[0] == request_msg -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_import_issue_model_empty_call_rest(): + client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.ContactCenterInsightsRestInterceptor(), + transport="rest", ) - client = ContactCenterInsightsClient(transport=transport) + # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.ContactCenterInsightsRestInterceptor, "pre_delete_view" - ) as pre: - pre.assert_not_called() - pb_message = contact_center_insights.DeleteViewRequest.pb( - contact_center_insights.DeleteViewRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - - request = contact_center_insights.DeleteViewRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata + type(client.transport.import_issue_model), "__call__" + ) as call: + client.import_issue_model(request=None) - client.delete_view( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ImportIssueModelRequest() - pre.assert_called_once() + assert args[0] == request_msg -def test_cancel_operation_rest_bad_request( - request_type=operations_pb2.CancelOperationRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_issue_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2/operations/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.cancel_operation(request) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + client.get_issue(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetIssueRequest() -@pytest.mark.parametrize( - "request_type", - [ - operations_pb2.CancelOperationRequest, - dict, - ], -) -def test_cancel_operation_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_issues_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = "{}" - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + client.list_issues(request=None) - response = client.cancel_operation(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListIssuesRequest() - # Establish that the response is the type that we expect. - assert response is None + assert args[0] == request_msg -def test_get_operation_rest_bad_request( - request_type=operations_pb2.GetOperationRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_issue_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2/operations/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_operation(request) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + client.update_issue(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.UpdateIssueRequest() -@pytest.mark.parametrize( - "request_type", - [ - operations_pb2.GetOperationRequest, - dict, - ], -) -def test_get_operation_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_issue_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation() + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + client.delete_issue(request=None) - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.DeleteIssueRequest() - req.return_value = response_value + assert args[0] == request_msg - response = client.get_operation(request) - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_calculate_issue_model_stats_empty_call_rest(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), "__call__" + ) as call: + client.calculate_issue_model_stats(request=None) -def test_list_operations_rest_bad_request( - request_type=operations_pb2.ListOperationsRequest, -): + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CalculateIssueModelStatsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_phrase_matcher_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_operations(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), "__call__" + ) as call: + client.create_phrase_matcher(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.CreatePhraseMatcherRequest() + assert args[0] == request_msg -@pytest.mark.parametrize( - "request_type", - [ - operations_pb2.ListOperationsRequest, - dict, - ], -) -def test_list_operations_rest(request_type): + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_phrase_matcher_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.ListOperationsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), "__call__" + ) as call: + client.get_phrase_matcher(request=None) - response = client.list_operations(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.GetPhraseMatcherRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) + assert args[0] == request_msg -def test_initialize_client_w_rest(): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_phrase_matchers_empty_call_rest(): client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - assert client is not None + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), "__call__" + ) as call: + client.list_phrase_matchers(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = contact_center_insights.ListPhraseMatchersRequest() + + assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_conversation_empty_call_rest(): +def test_delete_phrase_matcher_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33762,21 +58757,21 @@ def test_create_conversation_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_conversation), "__call__" + type(client.transport.delete_phrase_matcher), "__call__" ) as call: - client.create_conversation(request=None) + client.delete_phrase_matcher(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateConversationRequest() + request_msg = contact_center_insights.DeletePhraseMatcherRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_upload_conversation_empty_call_rest(): +def test_update_phrase_matcher_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33784,85 +58779,81 @@ def test_upload_conversation_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.upload_conversation), "__call__" + type(client.transport.update_phrase_matcher), "__call__" ) as call: - client.upload_conversation(request=None) + client.update_phrase_matcher(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UploadConversationRequest() + request_msg = contact_center_insights.UpdatePhraseMatcherRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_conversation_empty_call_rest(): +def test_calculate_stats_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), "__call__" - ) as call: - client.update_conversation(request=None) + with mock.patch.object(type(client.transport.calculate_stats), "__call__") as call: + client.calculate_stats(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateConversationRequest() + request_msg = contact_center_insights.CalculateStatsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_conversation_empty_call_rest(): +def test_get_settings_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_conversation), "__call__") as call: - client.get_conversation(request=None) + with mock.patch.object(type(client.transport.get_settings), "__call__") as call: + client.get_settings(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetConversationRequest() + request_msg = contact_center_insights.GetSettingsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_conversations_empty_call_rest(): +def test_update_settings_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), "__call__" - ) as call: - client.list_conversations(request=None) + with mock.patch.object(type(client.transport.update_settings), "__call__") as call: + client.update_settings(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListConversationsRequest() + request_msg = contact_center_insights.UpdateSettingsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_conversation_empty_call_rest(): +def test_create_analysis_rule_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33870,101 +58861,109 @@ def test_delete_conversation_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.delete_conversation), "__call__" + type(client.transport.create_analysis_rule), "__call__" ) as call: - client.delete_conversation(request=None) + client.create_analysis_rule(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteConversationRequest() + request_msg = contact_center_insights.CreateAnalysisRuleRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_analysis_empty_call_rest(): +def test_get_analysis_rule_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_analysis), "__call__") as call: - client.create_analysis(request=None) + with mock.patch.object( + type(client.transport.get_analysis_rule), "__call__" + ) as call: + client.get_analysis_rule(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateAnalysisRequest() + request_msg = contact_center_insights.GetAnalysisRuleRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_analysis_empty_call_rest(): +def test_list_analysis_rules_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_analysis), "__call__") as call: - client.get_analysis(request=None) + with mock.patch.object( + type(client.transport.list_analysis_rules), "__call__" + ) as call: + client.list_analysis_rules(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetAnalysisRequest() + request_msg = contact_center_insights.ListAnalysisRulesRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_analyses_empty_call_rest(): +def test_update_analysis_rule_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_analyses), "__call__") as call: - client.list_analyses(request=None) + with mock.patch.object( + type(client.transport.update_analysis_rule), "__call__" + ) as call: + client.update_analysis_rule(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListAnalysesRequest() + request_msg = contact_center_insights.UpdateAnalysisRuleRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_analysis_empty_call_rest(): +def test_delete_analysis_rule_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_analysis), "__call__") as call: - client.delete_analysis(request=None) + with mock.patch.object( + type(client.transport.delete_analysis_rule), "__call__" + ) as call: + client.delete_analysis_rule(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteAnalysisRequest() + request_msg = contact_center_insights.DeleteAnalysisRuleRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_bulk_analyze_conversations_empty_call_rest(): +def test_get_encryption_spec_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33972,21 +58971,21 @@ def test_bulk_analyze_conversations_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.bulk_analyze_conversations), "__call__" + type(client.transport.get_encryption_spec), "__call__" ) as call: - client.bulk_analyze_conversations(request=None) + client.get_encryption_spec(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.BulkAnalyzeConversationsRequest() + request_msg = contact_center_insights.GetEncryptionSpecRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_bulk_delete_conversations_empty_call_rest(): +def test_initialize_encryption_spec_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33994,151 +58993,141 @@ def test_bulk_delete_conversations_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.bulk_delete_conversations), "__call__" + type(client.transport.initialize_encryption_spec), "__call__" ) as call: - client.bulk_delete_conversations(request=None) + client.initialize_encryption_spec(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.BulkDeleteConversationsRequest() + request_msg = contact_center_insights.InitializeEncryptionSpecRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_ingest_conversations_empty_call_rest(): +def test_create_view_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), "__call__" - ) as call: - client.ingest_conversations(request=None) + with mock.patch.object(type(client.transport.create_view), "__call__") as call: + client.create_view(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.IngestConversationsRequest() + request_msg = contact_center_insights.CreateViewRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_export_insights_data_empty_call_rest(): +def test_get_view_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), "__call__" - ) as call: - client.export_insights_data(request=None) + with mock.patch.object(type(client.transport.get_view), "__call__") as call: + client.get_view(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ExportInsightsDataRequest() + request_msg = contact_center_insights.GetViewRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_issue_model_empty_call_rest(): +def test_list_views_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), "__call__" - ) as call: - client.create_issue_model(request=None) + with mock.patch.object(type(client.transport.list_views), "__call__") as call: + client.list_views(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateIssueModelRequest() + request_msg = contact_center_insights.ListViewsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_issue_model_empty_call_rest(): +def test_update_view_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), "__call__" - ) as call: - client.update_issue_model(request=None) + with mock.patch.object(type(client.transport.update_view), "__call__") as call: + client.update_view(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateIssueModelRequest() + request_msg = contact_center_insights.UpdateViewRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_issue_model_empty_call_rest(): +def test_delete_view_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: - client.get_issue_model(request=None) + with mock.patch.object(type(client.transport.delete_view), "__call__") as call: + client.delete_view(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetIssueModelRequest() + request_msg = contact_center_insights.DeleteViewRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_issue_models_empty_call_rest(): +def test_query_metrics_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), "__call__" - ) as call: - client.list_issue_models(request=None) + with mock.patch.object(type(client.transport.query_metrics), "__call__") as call: + client.query_metrics(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListIssueModelsRequest() + request_msg = contact_center_insights.QueryMetricsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_issue_model_empty_call_rest(): +def test_create_qa_question_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34146,43 +59135,41 @@ def test_delete_issue_model_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.delete_issue_model), "__call__" + type(client.transport.create_qa_question), "__call__" ) as call: - client.delete_issue_model(request=None) + client.create_qa_question(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteIssueModelRequest() + request_msg = contact_center_insights.CreateQaQuestionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_deploy_issue_model_empty_call_rest(): +def test_get_qa_question_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), "__call__" - ) as call: - client.deploy_issue_model(request=None) + with mock.patch.object(type(client.transport.get_qa_question), "__call__") as call: + client.get_qa_question(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeployIssueModelRequest() + request_msg = contact_center_insights.GetQaQuestionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_undeploy_issue_model_empty_call_rest(): +def test_update_qa_question_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34190,21 +59177,21 @@ def test_undeploy_issue_model_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.undeploy_issue_model), "__call__" + type(client.transport.update_qa_question), "__call__" ) as call: - client.undeploy_issue_model(request=None) + client.update_qa_question(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UndeployIssueModelRequest() + request_msg = contact_center_insights.UpdateQaQuestionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_export_issue_model_empty_call_rest(): +def test_delete_qa_question_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34212,21 +59199,21 @@ def test_export_issue_model_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.export_issue_model), "__call__" + type(client.transport.delete_qa_question), "__call__" ) as call: - client.export_issue_model(request=None) + client.delete_qa_question(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ExportIssueModelRequest() + request_msg = contact_center_insights.DeleteQaQuestionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_import_issue_model_empty_call_rest(): +def test_list_qa_questions_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34234,101 +59221,107 @@ def test_import_issue_model_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.import_issue_model), "__call__" + type(client.transport.list_qa_questions), "__call__" ) as call: - client.import_issue_model(request=None) + client.list_qa_questions(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ImportIssueModelRequest() + request_msg = contact_center_insights.ListQaQuestionsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_issue_empty_call_rest(): +def test_create_qa_scorecard_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_issue), "__call__") as call: - client.get_issue(request=None) + with mock.patch.object( + type(client.transport.create_qa_scorecard), "__call__" + ) as call: + client.create_qa_scorecard(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetIssueRequest() + request_msg = contact_center_insights.CreateQaScorecardRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_issues_empty_call_rest(): +def test_get_qa_scorecard_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_issues), "__call__") as call: - client.list_issues(request=None) + with mock.patch.object(type(client.transport.get_qa_scorecard), "__call__") as call: + client.get_qa_scorecard(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListIssuesRequest() + request_msg = contact_center_insights.GetQaScorecardRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_issue_empty_call_rest(): +def test_update_qa_scorecard_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_issue), "__call__") as call: - client.update_issue(request=None) + with mock.patch.object( + type(client.transport.update_qa_scorecard), "__call__" + ) as call: + client.update_qa_scorecard(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateIssueRequest() + request_msg = contact_center_insights.UpdateQaScorecardRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_issue_empty_call_rest(): +def test_delete_qa_scorecard_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: - client.delete_issue(request=None) + with mock.patch.object( + type(client.transport.delete_qa_scorecard), "__call__" + ) as call: + client.delete_qa_scorecard(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteIssueRequest() + request_msg = contact_center_insights.DeleteQaScorecardRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_calculate_issue_model_stats_empty_call_rest(): +def test_list_qa_scorecards_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34336,21 +59329,21 @@ def test_calculate_issue_model_stats_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.calculate_issue_model_stats), "__call__" + type(client.transport.list_qa_scorecards), "__call__" ) as call: - client.calculate_issue_model_stats(request=None) + client.list_qa_scorecards(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CalculateIssueModelStatsRequest() + request_msg = contact_center_insights.ListQaScorecardsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_phrase_matcher_empty_call_rest(): +def test_create_qa_scorecard_revision_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34358,21 +59351,21 @@ def test_create_phrase_matcher_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_phrase_matcher), "__call__" + type(client.transport.create_qa_scorecard_revision), "__call__" ) as call: - client.create_phrase_matcher(request=None) + client.create_qa_scorecard_revision(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreatePhraseMatcherRequest() + request_msg = contact_center_insights.CreateQaScorecardRevisionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_phrase_matcher_empty_call_rest(): +def test_get_qa_scorecard_revision_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34380,21 +59373,21 @@ def test_get_phrase_matcher_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_phrase_matcher), "__call__" + type(client.transport.get_qa_scorecard_revision), "__call__" ) as call: - client.get_phrase_matcher(request=None) + client.get_qa_scorecard_revision(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetPhraseMatcherRequest() + request_msg = contact_center_insights.GetQaScorecardRevisionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_phrase_matchers_empty_call_rest(): +def test_tune_qa_scorecard_revision_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34402,21 +59395,21 @@ def test_list_phrase_matchers_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_phrase_matchers), "__call__" + type(client.transport.tune_qa_scorecard_revision), "__call__" ) as call: - client.list_phrase_matchers(request=None) + client.tune_qa_scorecard_revision(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListPhraseMatchersRequest() + request_msg = contact_center_insights.TuneQaScorecardRevisionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_phrase_matcher_empty_call_rest(): +def test_deploy_qa_scorecard_revision_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34424,21 +59417,21 @@ def test_delete_phrase_matcher_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.delete_phrase_matcher), "__call__" + type(client.transport.deploy_qa_scorecard_revision), "__call__" ) as call: - client.delete_phrase_matcher(request=None) + client.deploy_qa_scorecard_revision(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeletePhraseMatcherRequest() + request_msg = contact_center_insights.DeployQaScorecardRevisionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_phrase_matcher_empty_call_rest(): +def test_undeploy_qa_scorecard_revision_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34446,81 +59439,87 @@ def test_update_phrase_matcher_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.update_phrase_matcher), "__call__" + type(client.transport.undeploy_qa_scorecard_revision), "__call__" ) as call: - client.update_phrase_matcher(request=None) + client.undeploy_qa_scorecard_revision(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdatePhraseMatcherRequest() + request_msg = contact_center_insights.UndeployQaScorecardRevisionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_calculate_stats_empty_call_rest(): +def test_delete_qa_scorecard_revision_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.calculate_stats), "__call__") as call: - client.calculate_stats(request=None) + with mock.patch.object( + type(client.transport.delete_qa_scorecard_revision), "__call__" + ) as call: + client.delete_qa_scorecard_revision(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CalculateStatsRequest() + request_msg = contact_center_insights.DeleteQaScorecardRevisionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_settings_empty_call_rest(): +def test_list_qa_scorecard_revisions_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_settings), "__call__") as call: - client.get_settings(request=None) + with mock.patch.object( + type(client.transport.list_qa_scorecard_revisions), "__call__" + ) as call: + client.list_qa_scorecard_revisions(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetSettingsRequest() + request_msg = contact_center_insights.ListQaScorecardRevisionsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_settings_empty_call_rest(): +def test_create_feedback_label_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_settings), "__call__") as call: - client.update_settings(request=None) + with mock.patch.object( + type(client.transport.create_feedback_label), "__call__" + ) as call: + client.create_feedback_label(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateSettingsRequest() + request_msg = contact_center_insights.CreateFeedbackLabelRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_encryption_spec_empty_call_rest(): +def test_list_feedback_labels_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34528,21 +59527,21 @@ def test_get_encryption_spec_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_encryption_spec), "__call__" + type(client.transport.list_feedback_labels), "__call__" ) as call: - client.get_encryption_spec(request=None) + client.list_feedback_labels(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetEncryptionSpecRequest() + request_msg = contact_center_insights.ListFeedbackLabelsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_initialize_encryption_spec_empty_call_rest(): +def test_get_feedback_label_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34550,114 +59549,124 @@ def test_initialize_encryption_spec_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.initialize_encryption_spec), "__call__" + type(client.transport.get_feedback_label), "__call__" ) as call: - client.initialize_encryption_spec(request=None) + client.get_feedback_label(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.InitializeEncryptionSpecRequest() + request_msg = contact_center_insights.GetFeedbackLabelRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_view_empty_call_rest(): +def test_update_feedback_label_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_view), "__call__") as call: - client.create_view(request=None) + with mock.patch.object( + type(client.transport.update_feedback_label), "__call__" + ) as call: + client.update_feedback_label(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.CreateViewRequest() + request_msg = contact_center_insights.UpdateFeedbackLabelRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_view_empty_call_rest(): +def test_delete_feedback_label_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_view), "__call__") as call: - client.get_view(request=None) + with mock.patch.object( + type(client.transport.delete_feedback_label), "__call__" + ) as call: + client.delete_feedback_label(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.GetViewRequest() + request_msg = contact_center_insights.DeleteFeedbackLabelRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_views_empty_call_rest(): +def test_list_all_feedback_labels_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_views), "__call__") as call: - client.list_views(request=None) + with mock.patch.object( + type(client.transport.list_all_feedback_labels), "__call__" + ) as call: + client.list_all_feedback_labels(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.ListViewsRequest() + request_msg = contact_center_insights.ListAllFeedbackLabelsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_view_empty_call_rest(): +def test_bulk_upload_feedback_labels_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_view), "__call__") as call: - client.update_view(request=None) + with mock.patch.object( + type(client.transport.bulk_upload_feedback_labels), "__call__" + ) as call: + client.bulk_upload_feedback_labels(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.UpdateViewRequest() + request_msg = contact_center_insights.BulkUploadFeedbackLabelsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_view_empty_call_rest(): +def test_bulk_download_feedback_labels_empty_call_rest(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_view), "__call__") as call: - client.delete_view(request=None) + with mock.patch.object( + type(client.transport.bulk_download_feedback_labels), "__call__" + ) as call: + client.bulk_download_feedback_labels(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = contact_center_insights.DeleteViewRequest() + request_msg = contact_center_insights.BulkDownloadFeedbackLabelsRequest() assert args[0] == request_msg @@ -34748,6 +59757,11 @@ def test_contact_center_insights_base_transport(): "calculate_stats", "get_settings", "update_settings", + "create_analysis_rule", + "get_analysis_rule", + "list_analysis_rules", + "update_analysis_rule", + "delete_analysis_rule", "get_encryption_spec", "initialize_encryption_spec", "create_view", @@ -34755,6 +59769,32 @@ def test_contact_center_insights_base_transport(): "list_views", "update_view", "delete_view", + "query_metrics", + "create_qa_question", + "get_qa_question", + "update_qa_question", + "delete_qa_question", + "list_qa_questions", + "create_qa_scorecard", + "get_qa_scorecard", + "update_qa_scorecard", + "delete_qa_scorecard", + "list_qa_scorecards", + "create_qa_scorecard_revision", + "get_qa_scorecard_revision", + "tune_qa_scorecard_revision", + "deploy_qa_scorecard_revision", + "undeploy_qa_scorecard_revision", + "delete_qa_scorecard_revision", + "list_qa_scorecard_revisions", + "create_feedback_label", + "list_feedback_labels", + "get_feedback_label", + "update_feedback_label", + "delete_feedback_label", + "list_all_feedback_labels", + "bulk_upload_feedback_labels", + "bulk_download_feedback_labels", "get_operation", "cancel_operation", "list_operations", @@ -35133,6 +60173,21 @@ def test_contact_center_insights_client_transport_session_collision(transport_na session1 = client1.transport.update_settings._session session2 = client2.transport.update_settings._session assert session1 != session2 + session1 = client1.transport.create_analysis_rule._session + session2 = client2.transport.create_analysis_rule._session + assert session1 != session2 + session1 = client1.transport.get_analysis_rule._session + session2 = client2.transport.get_analysis_rule._session + assert session1 != session2 + session1 = client1.transport.list_analysis_rules._session + session2 = client2.transport.list_analysis_rules._session + assert session1 != session2 + session1 = client1.transport.update_analysis_rule._session + session2 = client2.transport.update_analysis_rule._session + assert session1 != session2 + session1 = client1.transport.delete_analysis_rule._session + session2 = client2.transport.delete_analysis_rule._session + assert session1 != session2 session1 = client1.transport.get_encryption_spec._session session2 = client2.transport.get_encryption_spec._session assert session1 != session2 @@ -35154,6 +60209,84 @@ def test_contact_center_insights_client_transport_session_collision(transport_na session1 = client1.transport.delete_view._session session2 = client2.transport.delete_view._session assert session1 != session2 + session1 = client1.transport.query_metrics._session + session2 = client2.transport.query_metrics._session + assert session1 != session2 + session1 = client1.transport.create_qa_question._session + session2 = client2.transport.create_qa_question._session + assert session1 != session2 + session1 = client1.transport.get_qa_question._session + session2 = client2.transport.get_qa_question._session + assert session1 != session2 + session1 = client1.transport.update_qa_question._session + session2 = client2.transport.update_qa_question._session + assert session1 != session2 + session1 = client1.transport.delete_qa_question._session + session2 = client2.transport.delete_qa_question._session + assert session1 != session2 + session1 = client1.transport.list_qa_questions._session + session2 = client2.transport.list_qa_questions._session + assert session1 != session2 + session1 = client1.transport.create_qa_scorecard._session + session2 = client2.transport.create_qa_scorecard._session + assert session1 != session2 + session1 = client1.transport.get_qa_scorecard._session + session2 = client2.transport.get_qa_scorecard._session + assert session1 != session2 + session1 = client1.transport.update_qa_scorecard._session + session2 = client2.transport.update_qa_scorecard._session + assert session1 != session2 + session1 = client1.transport.delete_qa_scorecard._session + session2 = client2.transport.delete_qa_scorecard._session + assert session1 != session2 + session1 = client1.transport.list_qa_scorecards._session + session2 = client2.transport.list_qa_scorecards._session + assert session1 != session2 + session1 = client1.transport.create_qa_scorecard_revision._session + session2 = client2.transport.create_qa_scorecard_revision._session + assert session1 != session2 + session1 = client1.transport.get_qa_scorecard_revision._session + session2 = client2.transport.get_qa_scorecard_revision._session + assert session1 != session2 + session1 = client1.transport.tune_qa_scorecard_revision._session + session2 = client2.transport.tune_qa_scorecard_revision._session + assert session1 != session2 + session1 = client1.transport.deploy_qa_scorecard_revision._session + session2 = client2.transport.deploy_qa_scorecard_revision._session + assert session1 != session2 + session1 = client1.transport.undeploy_qa_scorecard_revision._session + session2 = client2.transport.undeploy_qa_scorecard_revision._session + assert session1 != session2 + session1 = client1.transport.delete_qa_scorecard_revision._session + session2 = client2.transport.delete_qa_scorecard_revision._session + assert session1 != session2 + session1 = client1.transport.list_qa_scorecard_revisions._session + session2 = client2.transport.list_qa_scorecard_revisions._session + assert session1 != session2 + session1 = client1.transport.create_feedback_label._session + session2 = client2.transport.create_feedback_label._session + assert session1 != session2 + session1 = client1.transport.list_feedback_labels._session + session2 = client2.transport.list_feedback_labels._session + assert session1 != session2 + session1 = client1.transport.get_feedback_label._session + session2 = client2.transport.get_feedback_label._session + assert session1 != session2 + session1 = client1.transport.update_feedback_label._session + session2 = client2.transport.update_feedback_label._session + assert session1 != session2 + session1 = client1.transport.delete_feedback_label._session + session2 = client2.transport.delete_feedback_label._session + assert session1 != session2 + session1 = client1.transport.list_all_feedback_labels._session + session2 = client2.transport.list_all_feedback_labels._session + assert session1 != session2 + session1 = client1.transport.bulk_upload_feedback_labels._session + session2 = client2.transport.bulk_upload_feedback_labels._session + assert session1 != session2 + session1 = client1.transport.bulk_download_feedback_labels._session + session2 = client2.transport.bulk_download_feedback_labels._session + assert session1 != session2 def test_contact_center_insights_grpc_transport_channel(): @@ -35347,10 +60480,40 @@ def test_parse_analysis_path(): assert expected == actual -def test_conversation_path(): +def test_analysis_rule_path(): project = "winkle" location = "nautilus" - conversation = "scallop" + analysis_rule = "scallop" + expected = ( + "projects/{project}/locations/{location}/analysisRules/{analysis_rule}".format( + project=project, + location=location, + analysis_rule=analysis_rule, + ) + ) + actual = ContactCenterInsightsClient.analysis_rule_path( + project, location, analysis_rule + ) + assert expected == actual + + +def test_parse_analysis_rule_path(): + expected = { + "project": "abalone", + "location": "squid", + "analysis_rule": "clam", + } + path = ContactCenterInsightsClient.analysis_rule_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_analysis_rule_path(path) + assert expected == actual + + +def test_conversation_path(): + project = "whelk" + location = "octopus" + conversation = "oyster" expected = ( "projects/{project}/locations/{location}/conversations/{conversation}".format( project=project, @@ -35366,9 +60529,9 @@ def test_conversation_path(): def test_parse_conversation_path(): expected = { - "project": "abalone", - "location": "squid", - "conversation": "clam", + "project": "nudibranch", + "location": "cuttlefish", + "conversation": "mussel", } path = ContactCenterInsightsClient.conversation_path(**expected) @@ -35378,9 +60541,9 @@ def test_parse_conversation_path(): def test_conversation_profile_path(): - project = "whelk" - location = "octopus" - conversation_profile = "oyster" + project = "winkle" + location = "nautilus" + conversation_profile = "scallop" expected = "projects/{project}/locations/{location}/conversationProfiles/{conversation_profile}".format( project=project, location=location, @@ -35394,9 +60557,9 @@ def test_conversation_profile_path(): def test_parse_conversation_profile_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "conversation_profile": "mussel", + "project": "abalone", + "location": "squid", + "conversation_profile": "clam", } path = ContactCenterInsightsClient.conversation_profile_path(**expected) @@ -35406,8 +60569,8 @@ def test_parse_conversation_profile_path(): def test_encryption_spec_path(): - project = "winkle" - location = "nautilus" + project = "whelk" + location = "octopus" expected = "projects/{project}/locations/{location}/encryptionSpec".format( project=project, location=location, @@ -35418,8 +60581,8 @@ def test_encryption_spec_path(): def test_parse_encryption_spec_path(): expected = { - "project": "scallop", - "location": "abalone", + "project": "oyster", + "location": "nudibranch", } path = ContactCenterInsightsClient.encryption_spec_path(**expected) @@ -35428,11 +60591,42 @@ def test_parse_encryption_spec_path(): assert expected == actual +def test_feedback_label_path(): + project = "cuttlefish" + location = "mussel" + conversation = "winkle" + feedback_label = "nautilus" + expected = "projects/{project}/locations/{location}/conversations/{conversation}/feedbackLabels/{feedback_label}".format( + project=project, + location=location, + conversation=conversation, + feedback_label=feedback_label, + ) + actual = ContactCenterInsightsClient.feedback_label_path( + project, location, conversation, feedback_label + ) + assert expected == actual + + +def test_parse_feedback_label_path(): + expected = { + "project": "scallop", + "location": "abalone", + "conversation": "squid", + "feedback_label": "clam", + } + path = ContactCenterInsightsClient.feedback_label_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_feedback_label_path(path) + assert expected == actual + + def test_issue_path(): - project = "squid" - location = "clam" - issue_model = "whelk" - issue = "octopus" + project = "whelk" + location = "octopus" + issue_model = "oyster" + issue = "nudibranch" expected = "projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}".format( project=project, location=location, @@ -35447,10 +60641,10 @@ def test_issue_path(): def test_parse_issue_path(): expected = { - "project": "oyster", - "location": "nudibranch", - "issue_model": "cuttlefish", - "issue": "mussel", + "project": "cuttlefish", + "location": "mussel", + "issue_model": "winkle", + "issue": "nautilus", } path = ContactCenterInsightsClient.issue_path(**expected) @@ -35460,9 +60654,9 @@ def test_parse_issue_path(): def test_issue_model_path(): - project = "winkle" - location = "nautilus" - issue_model = "scallop" + project = "scallop" + location = "abalone" + issue_model = "squid" expected = ( "projects/{project}/locations/{location}/issueModels/{issue_model}".format( project=project, @@ -35478,9 +60672,9 @@ def test_issue_model_path(): def test_parse_issue_model_path(): expected = { - "project": "abalone", - "location": "squid", - "issue_model": "clam", + "project": "clam", + "location": "whelk", + "issue_model": "octopus", } path = ContactCenterInsightsClient.issue_model_path(**expected) @@ -35490,9 +60684,9 @@ def test_parse_issue_model_path(): def test_participant_path(): - project = "whelk" - conversation = "octopus" - participant = "oyster" + project = "oyster" + conversation = "nudibranch" + participant = "cuttlefish" expected = "projects/{project}/conversations/{conversation}/participants/{participant}".format( project=project, conversation=conversation, @@ -35506,9 +60700,9 @@ def test_participant_path(): def test_parse_participant_path(): expected = { - "project": "nudibranch", - "conversation": "cuttlefish", - "participant": "mussel", + "project": "mussel", + "conversation": "winkle", + "participant": "nautilus", } path = ContactCenterInsightsClient.participant_path(**expected) @@ -35518,9 +60712,9 @@ def test_parse_participant_path(): def test_phrase_matcher_path(): - project = "winkle" - location = "nautilus" - phrase_matcher = "scallop" + project = "scallop" + location = "abalone" + phrase_matcher = "squid" expected = "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format( project=project, location=location, @@ -35534,9 +60728,9 @@ def test_phrase_matcher_path(): def test_parse_phrase_matcher_path(): expected = { - "project": "abalone", - "location": "squid", - "phrase_matcher": "clam", + "project": "clam", + "location": "whelk", + "phrase_matcher": "octopus", } path = ContactCenterInsightsClient.phrase_matcher_path(**expected) @@ -35545,10 +60739,133 @@ def test_parse_phrase_matcher_path(): assert expected == actual -def test_recognizer_path(): +def test_qa_question_path(): + project = "oyster" + location = "nudibranch" + qa_scorecard = "cuttlefish" + revision = "mussel" + qa_question = "winkle" + expected = "projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}/revisions/{revision}/qaQuestions/{qa_question}".format( + project=project, + location=location, + qa_scorecard=qa_scorecard, + revision=revision, + qa_question=qa_question, + ) + actual = ContactCenterInsightsClient.qa_question_path( + project, location, qa_scorecard, revision, qa_question + ) + assert expected == actual + + +def test_parse_qa_question_path(): + expected = { + "project": "nautilus", + "location": "scallop", + "qa_scorecard": "abalone", + "revision": "squid", + "qa_question": "clam", + } + path = ContactCenterInsightsClient.qa_question_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_qa_question_path(path) + assert expected == actual + + +def test_qa_scorecard_path(): + project = "whelk" + location = "octopus" + qa_scorecard = "oyster" + expected = ( + "projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}".format( + project=project, + location=location, + qa_scorecard=qa_scorecard, + ) + ) + actual = ContactCenterInsightsClient.qa_scorecard_path( + project, location, qa_scorecard + ) + assert expected == actual + + +def test_parse_qa_scorecard_path(): + expected = { + "project": "nudibranch", + "location": "cuttlefish", + "qa_scorecard": "mussel", + } + path = ContactCenterInsightsClient.qa_scorecard_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_qa_scorecard_path(path) + assert expected == actual + + +def test_qa_scorecard_result_path(): + project = "winkle" + location = "nautilus" + qa_scorecard_result = "scallop" + expected = "projects/{project}/locations/{location}/qaScorecardResults/{qa_scorecard_result}".format( + project=project, + location=location, + qa_scorecard_result=qa_scorecard_result, + ) + actual = ContactCenterInsightsClient.qa_scorecard_result_path( + project, location, qa_scorecard_result + ) + assert expected == actual + + +def test_parse_qa_scorecard_result_path(): + expected = { + "project": "abalone", + "location": "squid", + "qa_scorecard_result": "clam", + } + path = ContactCenterInsightsClient.qa_scorecard_result_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_qa_scorecard_result_path(path) + assert expected == actual + + +def test_qa_scorecard_revision_path(): project = "whelk" location = "octopus" - recognizer = "oyster" + qa_scorecard = "oyster" + revision = "nudibranch" + expected = "projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}/revisions/{revision}".format( + project=project, + location=location, + qa_scorecard=qa_scorecard, + revision=revision, + ) + actual = ContactCenterInsightsClient.qa_scorecard_revision_path( + project, location, qa_scorecard, revision + ) + assert expected == actual + + +def test_parse_qa_scorecard_revision_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + "qa_scorecard": "winkle", + "revision": "nautilus", + } + path = ContactCenterInsightsClient.qa_scorecard_revision_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_qa_scorecard_revision_path(path) + assert expected == actual + + +def test_recognizer_path(): + project = "scallop" + location = "abalone" + recognizer = "squid" expected = ( "projects/{project}/locations/{location}/recognizers/{recognizer}".format( project=project, @@ -35562,9 +60879,9 @@ def test_recognizer_path(): def test_parse_recognizer_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "recognizer": "mussel", + "project": "clam", + "location": "whelk", + "recognizer": "octopus", } path = ContactCenterInsightsClient.recognizer_path(**expected) @@ -35574,8 +60891,8 @@ def test_parse_recognizer_path(): def test_settings_path(): - project = "winkle" - location = "nautilus" + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}/settings".format( project=project, location=location, @@ -35586,8 +60903,8 @@ def test_settings_path(): def test_parse_settings_path(): expected = { - "project": "scallop", - "location": "abalone", + "project": "cuttlefish", + "location": "mussel", } path = ContactCenterInsightsClient.settings_path(**expected) @@ -35597,9 +60914,9 @@ def test_parse_settings_path(): def test_view_path(): - project = "squid" - location = "clam" - view = "whelk" + project = "winkle" + location = "nautilus" + view = "scallop" expected = "projects/{project}/locations/{location}/views/{view}".format( project=project, location=location, @@ -35611,9 +60928,9 @@ def test_view_path(): def test_parse_view_path(): expected = { - "project": "octopus", - "location": "oyster", - "view": "nudibranch", + "project": "abalone", + "location": "squid", + "view": "clam", } path = ContactCenterInsightsClient.view_path(**expected) @@ -35623,7 +60940,7 @@ def test_parse_view_path(): def test_common_billing_account_path(): - billing_account = "cuttlefish" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -35633,7 +60950,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "mussel", + "billing_account": "octopus", } path = ContactCenterInsightsClient.common_billing_account_path(**expected) @@ -35643,7 +60960,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "winkle" + folder = "oyster" expected = "folders/{folder}".format( folder=folder, ) @@ -35653,7 +60970,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nautilus", + "folder": "nudibranch", } path = ContactCenterInsightsClient.common_folder_path(**expected) @@ -35663,7 +60980,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "scallop" + organization = "cuttlefish" expected = "organizations/{organization}".format( organization=organization, ) @@ -35673,7 +60990,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "abalone", + "organization": "mussel", } path = ContactCenterInsightsClient.common_organization_path(**expected) @@ -35683,7 +61000,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "squid" + project = "winkle" expected = "projects/{project}".format( project=project, ) @@ -35693,7 +61010,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "clam", + "project": "nautilus", } path = ContactCenterInsightsClient.common_project_path(**expected) @@ -35703,8 +61020,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "whelk" - location = "octopus" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -35715,8 +61032,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "oyster", - "location": "nudibranch", + "project": "squid", + "location": "clam", } path = ContactCenterInsightsClient.common_location_path(**expected)