bookmark_borderbookmark
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Google Ads API에서 일부 메시지 필드는 campaign.manual_cpm와 같이 빈 메시지 객체로 정의되거나 설정할 필요가 없는 선택적 필드만 있을 수 있습니다(예: campaign.manual_cpc).
이러한 필드를 설정하는 것은 API에 특정 캠페인에 사용할 입찰 전략을 알려주는 데 중요하지만 메시지가 비어 있으면 직관적이지 않습니다.
문자열인 campaign.name 필드를 업데이트할 때는 마치 일반 Python 객체 속성인 것처럼 직접 업데이트하여 필드를 설정합니다.
campaign.name="Test campaign value"
campaign.manual_cpc는 중첩된 필드입니다. 즉, 문자열과 같은 원시 유형이 아닌 다른 protobuf 메시지가 포함됩니다. 필드를 직접 업데이트할 수도 있습니다.
campaign.manual_cpc.enhanced_cpc_enabled=True
이렇게 하면 API에 이 캠페인의 입찰 전략이 manual_cpc이고 향상된 CPC가 사용 설정되어 있다고 알립니다.
하지만 비어 있는 manual_cpm를 사용하려면 어떻게 해야 할까요? 아니면 향상된 CPC를 사용 설정하지 않은 manual_cpc인가요? 이렇게 하려면 클래스의 별도의 빈 인스턴스를 캠페인에 복사해야 합니다. 예를 들면 다음과 같습니다.
manual_cpm 필드는 설정되어 있지만 해당 필드에 값이 없습니다. 이 패턴을 사용하는 API에 요청을 전송할 때 로깅을 사용 설정하고 요청 페이로드를 검사하여 빈 메시지 객체를 올바르게 설정하고 있는지 확인할 수 있습니다.
마지막으로 이 필드를 요청 객체의 update_mask에 수동으로 추가해야 합니다. 필드 마스크 도우미에는 명시적으로 빈 객체로 설정된 필드와 설정되지 않은 필드의 차이를 결정하는 메커니즘이 없습니다.
fromgoogle.api_core.protobuf_helpersimportfield_maskcampaign_operation.create=campaigncampaign_operation.update_mask=field_mask(None,campaign)# Here we manually add the "manual_cpm" fieldcampaign_operation.update_mask.append("manual_cpm")
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-03-29(UTC)"],[[["Some Google Ads API message fields are defined as empty or only have optional fields, requiring specific handling to indicate the intended bidding strategy."],["To set a bidding strategy using an empty message field (like `manual_cpm`), you need to copy a separate empty instance of the corresponding class onto the campaign object."],["Nested fields within messages (like `campaign.manual_cpc.enhanced_cpc_enabled`) can be updated directly like normal Python object attributes."],["When using empty message objects, ensure the field is added to the request's `update_mask` manually, as the field mask helper cannot automatically detect this."]]],[]]